Skip to content

Instantly share code, notes, and snippets.

@jonahlyn
Last active June 24, 2020 02:37
Show Gist options
  • Save jonahlyn/888882301a48fb527d30 to your computer and use it in GitHub Desktop.
Save jonahlyn/888882301a48fb527d30 to your computer and use it in GitHub Desktop.
Python HTTP Server #python

Launch a Simple HTTP Server with Python

Change the directory to the location of the files you want to expose:

mkdir /tmp/nothing && cd /tmp/nothing

Default port 8000:

python -m SimpleHTTPServer

Change the port

sudo python -m SimpleHTTPServer 80

Python3 equivalent:

sudo python -m http.server 80

Create a webserver and log everything to a file[1]:

PYTHONUNBUFFERED=x python3 -m http.server &> /tmp/http.server.log & echo $! > /tmp/http.server.pid

[1] https://stackoverflow.com/questions/46665484/python3-http-server-save-log-to-a-file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment