Saturday, January 25, 2020

Python3 Version of simpleHTTPserver or Where Did SimpleHTTPserver Go in Python3

For those familiar with using python 2's simpleHTTPserver, it is a fast and easy way to start up a web server that can show contents of a directory.


In Python 2.X running python -m simpleHTTPserver starts a web server on port 8000 from the current directory.

In Python 3.X the new way to start up a simple http server is python3 -m http.server

By default the webserver spawned will use port 8000. You can specify a port after http.server
python3 -m http.server 9000


Starting http server:

Browsing the web server, locally with http://localhost:8000, notice you can now view/download/etc files from the directory the script was run from. 


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.