“Ad-hoc webserver” for static files on UNIX/MacOSX?

前端 未结 4 1608
你的背包
你的背包 2021-01-31 14:32

Is there such a thing as a tiny little webserver that I can invoke from the command line that just fetches files from the local filesystem and serves them via HTTP on specific p

4条回答
  •  难免孤独
    2021-01-31 15:12

    Python3 can serve the current directory via HTTP using http.server:

    $ python3 -m http.server
    

    Where

    • python3 the current version of python
    • -m stands for module
    • http the http package
    • http.server the server module (of the http package)

    Per default, http.server listens on port 8000, but you can specify another like this:

    $ python3 -m http.server 8080
    

提交回复
热议问题