DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Python : Simplest Http Server With Cherrypy

09.08.2005
| 4948 views |
  • submit to reddit
        taken from http://www.cherrypy.org/wiki/CherryPyTutorial
in the browser, return a "Hello world!" at http://localhost:8080(/index)
from cherrypy import cpg

class HelloWorld:

    @cpg.expose
    def index(self):
        return "Hello world!"

cpg.root = HelloWorld()
cpg.server.start()