There is a standard library called http.server
in the Python 3 series that allows you to host a directory in a local environment. It is provided as a SimpleHTTPServer
in the Python 2 series, and was useful for hosting web pages in the local environment in a simple way.
simplehttp2server
http.server
is hosted by http/1.1, but for those who want to host it by http/2, there is one called GoogleChromeLabs/simplehttp2server. It is a very useful tool, but you need to install it with Homebrew or go get
. I developed 1000ch/simplehttp2server as a Node.js wrapper for GoogleChromeLabs/simplehttp2server to make it easy to use it in Web Frontend projects.
That said, it's been about 5 years since I published simplehttp2server in npm, so it's nothing new. A recent change was made to this Node.js wrapper and the command line package that separated it.
simplehttp2server-cli
So now there are simplehttp2server and simplehttp2server-cli packages wrapping binaries. In order to run simplehttp2server on the command line, you need to install the latter.
$ npm install -g simplehttp2server-cli
$ simplehttp2server --help
-config string
Config file
-cors string
Set allowed origins (default "*")
-listen string
Port to listen on (default ":5000")
Now, simplehttp2server can work, and folders in the local environment can be easily hosted with http/2. Note that since this is http/2, it will be accompanied by https, and the default port will be https://localhost:5000
. And Google Chrome can't open https://localhost
by default due to security issues.
If you enable #allow-insecure-localhost
flag from chrome://flags
and restart Google Chrome, you can also open https://localhost
.
Top comments (0)