Friday, September 23, 2011

Simple http server using python

This tip is really useful when you need a really quick web server running without too much hassle. Python comes with http server built-in that you can activate in a matter of seconds if you have python already installed. If you haven't install it, you might need an additional few minutes to install it. Below are the steps (this is assuming you are using redhat/fedora linux):

1. open a terminal and install python

# yum install python
2. Once done, browse to any directory that you want to be your document root directory, in this example I'll use /home/myuser
# cd /home/myuser
3. Run the below command to start the simple http server, where 8000 is the port number the server will use
# python -m SimpleHTTPServer 8000
Serving HTTP on port 8000 ...
4. Now open a browser, and type to access the server, where is your machine's ip address

No comments: