Sunday, January 29, 2012

Create a very Simple Python HTTP sever

This is what I would going to tell is something awesome in Python and Linux. Most of the time we need to share our stuff among the LANs and some time we needed to create HTTP serves. Python has given a very simple solution for this. Python comes with a small inbuilt HTTP server and you can easily convert any of your directories into a web server by using a single command.

Lets say you need to share your home account with others.
cd /home/prabodha
Then, You have to just type this on your command line and press enter
python -m SimpleHTTPServer
Now your sever is up and running,Then It will out put something like this

Serving HTTP on 0.0.0.0 port 8000 ...
Now any one in your LAN can access your server via HTTP://YOURIP:8000
http://192.168.1.2:8000
And you can access you sever via localhost
http://127.0.0.1:8000
Have fun with your very simple http web sever without installing apache or something similar.





No comments:

Post a Comment