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.

130 lines
3.4 KiB

10 years ago
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
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)](https://www.npmjs.org/package/local-web-server)
  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. $ ws --config
  21. $ ws --help|-h
  22. ```
  23. From the folder you wish to serve, run:
  24. ```sh
  25. $ ws
  26. serving at http://localhost:8000
  27. ```
  28. If you wish to serve a different directory, run:
  29. ```sh
  30. $ ws -d ~/mysite/
  31. serving /Users/Lloyd/mysite at http://localhost:8000
  32. ```
  33. If you wish to override the default port (8000), use `--port` or `-p`:
  34. ```sh
  35. $ ws --port 9000
  36. serving at http://localhost:9000
  37. ```
  38. Use a built-in or custom [Connect logger format](http://www.senchalabs.org/connect/logger.html) with `--log-format`:
  39. ```sh
  40. $ ws --log-format short
  41. ```
  42. To add compression, reducing bandwidth, increasing page load time (by 10-15% on my Macbook Air)
  43. ```sh
  44. $ ws --compress
  45. ```
  46. Storing default options
  47. -----------------------
  48. 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`:
  49. ```json
  50. {
  51. "name": "my-project",
  52. "version": "0.11.8",
  53. "local-web-server":{
  54. "port": 8100
  55. }
  56. }
  57. ```
  58. Or in a `.local-web-server.json` file stored in the directory you want to serve (typically the root folder of your site):
  59. ```json
  60. {
  61. "port": 8100,
  62. "log-format": "tiny"
  63. }
  64. ```
  65. Or store global defaults in a `.local-web-server.json` file in your home directory.
  66. ```json
  67. {
  68. "port": 3000
  69. }
  70. ```
  71. All stored defaults are overriden by options supplied at the command line.
  72. To view your stored defaults, run:
  73. ```sh
  74. $ ws --config
  75. ```
  76. Use with Logstalgia
  77. -------------------
  78. The "default" log-format is compatible with [logstalgia](http://code.google.com/p/logstalgia/).
  79. ###Install Logstalgia
  80. On MacOSX, install with [homebrew](http://brew.sh):
  81. ```sh
  82. $ brew install logstalgia
  83. ```
  84. Alternatively, [download a release for your system from github](https://github.com/acaudwell/Logstalgia/releases/latest).
  85. Then pipe the `default` output directly into logstalgia for real-time visualisation:
  86. ```sh
  87. $ ws -f default | logstalgia -
  88. ```
  89. ![local-web-server with logstalgia](http://75lb.github.io/local-web-server/logstagia.gif)
  90. Use with glTail
  91. ---------------
  92. To use with [glTail](http://www.fudgie.org), write your log to disk using the "default" format:
  93. ```sh
  94. $ ws -f default > web.log
  95. ```
  96. Then specify this file in your glTail config:
  97. ```yaml
  98. servers:
  99. dev:
  100. host: localhost
  101. source: local
  102. files: /Users/Lloyd/Documents/MySite/web.log
  103. parser: apache
  104. color: 0.2, 0.2, 1.0, 1.0
  105. ```