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.

69 lines
1.9 KiB

8 years ago
  1. # http-server: a command-line http server
  2. `http-server` is a simple, zero-configuration command-line http server. It is powerful enough for production usage, but it's simple and hackable enough to be used for testing, local development, and learning.
  3. ![](https://github.com/nodeapps/http-server/raw/master/screenshots/public.png)
  4. # Installing globally:
  5. Installation via `npm`:
  6. npm install http-server -g
  7. This will install `http-server` globally so that it may be run from the command line.
  8. ## Usage:
  9. http-server [path] [options]
  10. `[path]` defaults to `./public` if the folder exists, and `./` otherwise.
  11. # Installing as a node app
  12. mkdir myapp
  13. cd myapp/
  14. jitsu install http-server
  15. *If you do not have `jitsu` installed you can install it via `npm install jitsu -g`*
  16. ## Usage
  17. ### Starting http-server locally
  18. node bin/http-server
  19. *Now you can visit http://localhost:8080 to view your server*
  20. ## Available Options:
  21. `-p` Port to use (defaults to 8080)
  22. `-a` Address to use (defaults to 0.0.0.0)
  23. `-d` Show directory listings (defaults to 'True')
  24. `-i` Display autoIndex (defaults to 'True')
  25. `-e` or `--ext` Default file extension if none supplied (defaults to 'html')
  26. `-s` or `--silent` Suppress log messages from output
  27. `--cors` Enable CORS via the `Access-Control-Allow-Origin` header
  28. `-o` Open browser window after starting the server
  29. `-c` Set cache time (in seconds) for cache-control max-age header, e.g. -c10 for 10 seconds (defaults to '3600'). To disable caching, use -c-1.
  30. `-U` or `--utc` Use UTC time format in log messages.
  31. `-P` or `--proxy` Proxies all requests which can't be resolved locally to the given url. e.g.: -P http://someurl.com
  32. `-S` or `--ssl` Enable https.
  33. `-C` or `--cert` Path to ssl cert file (default: cert.pem).
  34. `-K` or `--key` Path to ssl key file (default: key.pem).
  35. `-r` or `--robots` Provide a /robots.txt (whose content defaults to 'User-agent: *\nDisallow: /')
  36. `-h` or `--help` Print this list and exit.