Theme images by Storman. Powered by Blogger.

Thursday 29 September 2016

Setup a simple server using Python

Today I will share you how to setup server quickly using Python in Windows in 5 easy steps.

Step 1 : Download python

Go to Python's official site and select the suitable version for your system and download.
Here is the link to download : https://www.python.org/downloads/

          
Step 2 : Install it

To install Python go to download location on your computer, double click the file and press Run when pop-up appears.

If you have multiple accounts on your computer and you don’t want to install it for all, select the “Install just for me” option then press "Next". move forward and finish the installation process.

Step 3 : Add Python to System Path Variable

Go to control panel then “Edit the system environment variables". when “System Properties” window appears, click on “Environment Variables…” and click on "New.." which appears in the bottom.


Give Variable name as "Path" and Variable value  as "c:\python27;c:\python27\script" . Variable value depends on where you Python script folder resides.


Step 4 : Run server

Go to your project directory and run given command.

#  for Python 2
python -m SimpleHTTPServer <portNo>

# for Python 3
python -m http.server <portNo>
or
python -m http.server

ex.
python -m http.server

For example, I run Python3.3 and the command I use is python -m http.server



Step 5 : Run URL in browser

 At last, go to your favorite browser.
 Paste the given URL in address bar  " http://localhost:8000/index.html "  and enter now, you can debug  your application in browser.








0 on: "Setup a simple server using Python "