Run a simple lightweight Python server

When you are developing websites you often run into the need to test them on a server environment, because browsers block websites with certain features from running locally.

Here is a really quick way to run such a website in a server environment using Python 3 (which you probably have already installed on your machine anyways).

  1. Open the command window where your website root folder is. One easy way of doing that is simply typing “cmd” in the Windows Explorer address bar.
  2. Type this command in the command window:
python -m http.server 8000
  1. Now simply go to in your browser.

If you are getting errors regarding script files with that simple version, you can also try this longer code:

#Use to create local host
import http.server
import socketserver

PORT = 1337

Handler = http.server.SimpleHTTPRequestHandler
      ".js": "application/javascript",

httpd = socketserver.TCPServer(("", PORT), Handler)

And open that with:

Leave a Reply

Your email address will not be published. Required fields are marked *