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
httpd.serve_forever()

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

python2

However in Windows you will receive this error message:

python.exe: No module named SimpleHTTPServer

python1

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 !

Be the first to comment on "python.exe: No module named SimpleHTTPServer – how to run it on Windows"

Leave a comment

Your email address will not be published.


*


Get Adobe Flash player Plugin by wpburn.com wordpress themes