Python simple HTTP server

If you are using Python3 and if you try to start the SimpleHTTPServer then you will get the error like No module named SimpleHTTPServer. It is because it is merged with http.server module. You can use the below command to run the python HTTP server in Python 3.

python3 -m http.server 8080

App.py example

# app.py

import http.server
import socketserver

PORT = 8000

Handler = http.server.SimpleHTTPRequestHandler

with socketserver.TCPServer(("", PORT), Handler) as httpd:
    print("serving at port", PORT)
    httpd.serve_forever()

Start the app

python3 app.py

Photo by Mikael Kristenson on Unsplash