python.exe: No module named SimpleHTTPServer – how to run it on Windows

SimpleHTTPServer  is very handy tool, Python module. It allows you to run temporary web server on your machine very quickly and without extra setup if you need to share some files with your users, colleagues on the network. You do not need to have installed Cyqwin, however you need to install Python.

The SimpleHTTPServer module is used in this manner:

import SimpleHTTPServer
import SocketServer
PORT = 8000
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SocketServer.TCPServer(("", PORT), Handler)
print "serving at port", PORT

You can start the SimpleHTTPServer by using this command on Mac/Linux and you will be sharing content of the directory where you executed this command:

python -m SimpleHTTPServer 8000


However in Windows you will receive this error message:

python.exe: No module named SimpleHTTPServer


Here is easy fix, in Windows has been this module renamed in Python and you need to use this command line instead:

python -m http.server 8000

All is good !

2 Replies to “python.exe: No module named SimpleHTTPServer – how to run it on Windows”

    1. You have to in command line navigate to the folder which you want to host on the server and start the http.server from that directory. Once done you will see listing all files,folders in web browser.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.