PUBLICATION_DATE: 2023.01.20

Start a simple webserver in current directory

DOMAIN: DevOps/Local-Development

« BACK TO NOTES

Simple PythonHttpServer

The following examples start a simple webserver serving the current directory. Only static files are supported. No server-side scripting languages are evaluated. Simple webservers may be useful for quick local network tests or local website development purposes.

As there is no in-built support for TLS/HTTPS, starting webservers this way should never be used for production purposes.

Using Python3

Read more on Python.org.

python3 -m http.server

This starts a server on port 8000 by default. Access at http://localhost:8000

To specify a custom port (note: ports below 1024 require sudo):

python3 -m http.server 8080

Press Ctrl+C to stop the server.

Using Python2

Read more on Python.org.

python2 -m SimpleHTTPServer 8000