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.

122 lines
3.1 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
11 years ago
11 years ago
  1. [![view on npm](http://img.shields.io/npm/v/local-web-server.svg)](https://www.npmjs.org/package/local-web-server)
  2. ![npm module downloads per month](http://img.shields.io/npm/dm/local-web-server.svg)
  3. [![Dependency Status](https://david-dm.org/75lb/local-web-server.svg)](https://david-dm.org/75lb/local-web-server)
  4. ![Analytics](https://ga-beacon.appspot.com/UA-27725889-12/local-web-server/README.md?pixel)
  5. local-web-server
  6. ================
  7. Fires up a simple, static web server on a given port. A pure Javascript (and more reliable) alternative to `$ python -mSimpleHTTPServer 8000`.
  8. Use for local web development or file sharing (directory browsing enabled). Plays well with Google Chrome Workspaces.
  9. Install
  10. -------
  11. Install [Node.js](http://nodejs.org), then run
  12. ```sh
  13. $ npm install -g local-web-server
  14. ```
  15. *Linux/Mac users may need to run the above with `sudo`*
  16. Usage
  17. -----
  18. ```
  19. ws [--directory|-d <directory>] [--port|-p <port>] [--log-format|-f dev|default|short|tiny] [--compress|-c]
  20. ```
  21. From the folder you wish to serve, run:
  22. ```sh
  23. $ ws
  24. serving at http://localhost:8000
  25. ```
  26. If you wish to serve a different directory, run:
  27. ```sh
  28. $ ws -d ~/mysite/
  29. serving /Users/Lloyd/mysite at http://localhost:8000
  30. ```
  31. If you wish to override the default port (8000), use `--port` or `-p`:
  32. ```sh
  33. $ ws --port 9000
  34. serving at http://localhost:9000
  35. ```
  36. Use a built-in or custom [Connect logger format](http://www.senchalabs.org/connect/logger.html) with `--log-format`:
  37. ```sh
  38. $ ws --log-format short
  39. ```
  40. To add compression, reducing bandwidth, increasing page load time (by 10-15% on my Macbook Air)
  41. ```sh
  42. $ ws --compress
  43. ```
  44. Storing default options
  45. -----------------------
  46. To store per-project options, saving you the hassle of inputting them everytime, store them in the `local-web-server` property of your project's `package.json`:
  47. ```json
  48. {
  49. "name": "my-project",
  50. "version": "0.11.8",
  51. "local-web-server":{
  52. "port": 8100
  53. }
  54. }
  55. ```
  56. Or in a `.local-web-server.json` file stored in the directory you want to serve (typically the root folder of your site):
  57. ```json
  58. {
  59. "port": 8100,
  60. "log-format": "tiny"
  61. }
  62. ```
  63. Or store global defaults in a `.local-web-server.json` file in your home directory.
  64. ```json
  65. {
  66. "port": 3000
  67. }
  68. ```
  69. All stored defaults are overriden by options supplied at the command line.
  70. Use with Logstalgia
  71. -------------------
  72. The "default" log-format is compatible with [logstalgia](http://code.google.com/p/logstalgia/).
  73. If you wrote your log output to disk, like so:
  74. ```sh
  75. $ ws --log-format default > web.log
  76. ```
  77. Then you could visualise in logstalgia with:
  78. ```sh
  79. $ logstalgia web.log
  80. ```
  81. Alternatively, pipe directly from ws into logstalgia for real-time visualisation:
  82. ```sh
  83. $ ws --log-format default | logstalgia -
  84. ```
  85. Use with glTail
  86. ---------------
  87. To use with [glTail](http://www.fudgie.org), write your log to disk using the "default" format:
  88. ```sh
  89. $ ws -f default > web.log
  90. ```
  91. Then specify this file in your glTail config:
  92. ```yaml
  93. servers:
  94. dev:
  95. host: localhost
  96. source: local
  97. files: /Users/Lloyd/Documents/MySite/web.log
  98. parser: apache
  99. color: 0.2, 0.2, 1.0, 1.0
  100. ```