SimpleHTTPServer is very handy tool, [easyazon_link identifier=”B00ZOAQ7S0″ locale=”US” tag=”wn0d5-20″] Python [/easyazon_link] 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 [easyazon_link identifier=”1449359361″ locale=”US” tag=”wn0d5-20″] Python [/easyazon_link].
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
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 [easyazon_link identifier=”1449340377″ locale=”US” tag=”wn0d5-20″] Python [/easyazon_link] and you need to use this command line instead:
python -m http.server 8000
All is good !
[easyazon_image align=”none” height=”160″ identifier=”1449340377″ locale=”US” src=”http://blog.technotesdesk.com/wp-content/uploads/2015/07/512zkd28xwL._SL160_.jpg” tag=”wn0d5-20″ width=”122″]
Hi,
I used it but I’m not able to post a file to the http server.
How can I do that?
Thanks.
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.