23.8.14

Simple HTTP Server with Python

Often, while developing web applications, I need to try it on a local server.
Apache is perfect, but sometimes I want to do it more faster and simpler.
Well, I discovered a python tool that in a simple line lets me to test a web application on localhost.

Let's assume that I would like to share the directory /home/testapp, where I have index.html file and related web files.
From a terminal, go in the directory you want and digit:
python -m SimpleHTTPServer 
That's it!  
Your web application is now running at http://localhost:8000.
You can obviously change the port, adding the port number at the end of the command, like this: python -m SimpleHTTPServer 8080
Really a cool tip to not forget!

Note: if you have python 3.x the command is: python -m http.server

Nessun commento:

Posta un commento