Make a web server using python
Posted In:
Python
,
web server
.
By Nikhilvishnupv
Making a web server using python is very easy. It is done by using web frameworks of python.Here we are using Web.py as a web framework. For using python first you have to install python in your system. In linux and unix os's python is a built in language. Windows version of python can be download from www.python.org.Download and install latest version of python. from http://webpy.org/ download and install web.py. Installing web.py is a very easy one. Extract the file in a folder using command prompt go to the folder and type.
>>python setup.py install
This will install Web.py.
Writing the first application
code.py
-----------
import web
urls = ('/', 'index' )
class index:
def GET(self):
print "Hello World!"
if __name__ == "__main__": web.run(urls, globals())
This is a Hello world program. Copy this code and save it as "code.py" . Run this file using command prompt by using the command
>>python code.py
this will give you a message like the below one.
>>http://0.0.0.0:8080/
This tells us that our system became a server and it serve the data through the port 8080. You can see the "Hello World!" message by typing the address http://localhost:8080/ in your browser.If all thigs worked well you can see Hello World! message in your browser. You can use the python functionalities for making complex codes for the server. The html pages are served using templates.
1 Response to Make a web server using python
superbbbb.........!!!!!!!!!!!!
Something to say?