You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.4 KiB

11 years ago
11 years ago
11 years ago
11 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
12 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. [![NPM version](https://badge.fury.io/js/local-web-server.png)](http://badge.fury.io/js/local-web-server)
  2. [![Dependency Status](https://david-dm.org/75lb/local-web-server.png)](https://david-dm.org/75lb/local-web-server)
  3. ![Analytics](https://ga-beacon.appspot.com/UA-27725889-12/local-web-server/README.md?pixel)
  4. local-web-server
  5. ================
  6. Fires up a simple, static web server on a given port. A pure Javascript (and more reliable) alternative to `$ python -mSimpleHTTPServer 8000`.
  7. Use for local web development or file sharing (directory browsing enabled). Plays well with Google Chrome Workspaces.
  8. Install
  9. -------
  10. Install [Node.js](http://nodejs.org), then run
  11. ```sh
  12. $ npm install -g local-web-server
  13. ```
  14. *Linux/Mac users may need to run the above with `sudo`*
  15. Usage
  16. -----
  17. ```
  18. ws [--directory|-d <directory>] [--port|-p <port>] [--log-format|-f dev|default|short|tiny] [--compress|-c]
  19. ```
  20. From the folder you wish to serve, run:
  21. ```sh
  22. $ ws
  23. serving at http://localhost:8000
  24. ```
  25. If you wish to serve a different directory, run:
  26. ```sh
  27. $ ws -d ~/mysite/
  28. serving /Users/Lloyd/mysite at http://localhost:8000
  29. ```
  30. If you wish to override the default port (8000), use `--port` or `-p`:
  31. ```sh
  32. $ ws --port 9000
  33. serving at http://localhost:9000
  34. ```
  35. Use a built-in or custom [Connect logger format](http://www.senchalabs.org/connect/logger.html) with `--log-format`:
  36. ```sh
  37. $ ws --log-format short
  38. ```
  39. To add compression, reducing bandwidth, increasing page load time (by 10-15% on my Macbook Air)
  40. ```sh
  41. $ ws --compress
  42. ```
  43. Use with Logstalgia
  44. -------------------
  45. The "default" log-format is compatible with [logstalgia](http://code.google.com/p/logstalgia/).
  46. If you wrote your log output to disk, like so:
  47. ```sh
  48. $ ws --log-format default > web.log
  49. ```
  50. Then you could visualise in logstalgia with:
  51. ```sh
  52. $ logstalgia web.log
  53. ```
  54. Alternatively, pipe directly from ws into logstalgia for real-time visualisation:
  55. ```sh
  56. $ ws --log-format default | logstalgia -
  57. ```
  58. Use with glTail
  59. ---------------
  60. To use with [glTail](http://www.fudgie.org), write your log to disk using the "default" format:
  61. ```sh
  62. $ ws -f default > web.log
  63. ```
  64. Then specify this file in your glTail config:
  65. ```yaml
  66. servers:
  67. dev:
  68. host: localhost
  69. source: local
  70. files: /Users/Lloyd/Documents/MySite/web.log
  71. parser: apache
  72. color: 0.2, 0.2, 1.0, 1.0
  73. ```
  74. [![NPM](https://nodei.co/npm-dl/local-web-server.png?months=3)](https://nodei.co/npm/local-web-server/)