Sunday, December 24, 2017

Start a simple http server using python3

This is very simple, because python3 already has a built in module for http server, called http.server. To use this module, run:

$ python3 -m http.server 8000

whereby 8000 is the port you want the http server to run on. To use privileged ports (under 1024) , just append sudo to the above command, like below:

$ sudo python3 -m http.server 80

Once the command run, you can access the current directory via web, like below:



Once done, press Ctrl-c to terminate the server.

No comments:

Post a Comment