quick static file server

February 1, 2024

© 2024 borui. All rights reserved. This content may be freely reproduced, displayed, modified, or distributed with proper attribution to borui and a link to the article: borui(2024-02-01 21:43:26 +0000). quick static file server. https://borui/blog/2024-02-01-en-quick-staticserver.
@misc{
  borui2024,
  author = {borui},
  title = {quick static file server},
  year = {2024},
  publisher = {borui's blog},
  journal = {borui's blog},
  url={https://borui/blog/2024-02-01-en-quick-staticserver}
}

python http.server

$ python3 -m http.server
# Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...


$ python3 -m http.server -d ~/Pictures/
# Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
  • Bartosz Zaczyński. (22 May, 2023.). How to Launch an HTTP Server in One Line of Python Code. realpython. [Blog post]. Retrieved February 1, 2024, https://realpython.com/python-http-server/

npm http-server

  • http-server. branch main. commit 8f7fcb0. https://github.com/http-party/http-server

Running on-demand:

Using npx you can run the script without installing it first:

npx http-server [path] [options]

npm serve

  • serve. branch main. commit 1ea55b1. https://github.com/vercel/serve

If you prefer, you can also install the package globally (you'll need at least Node LTS):

npm install --global serve

serve folder-name/

# Finally, run this command to see a list of all available options:
serve --help