User Tools

Site Tools


python:cherrypy_notes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

python:cherrypy_notes [2016/07/15 01:29] (current)
mithat created
Line 1: Line 1:
 +====== CherryPy Notes ======
  
 +Method names map to URLs. The following defines /index and /generate URLs:
 +<code python>
 +import random
 +import string
 +
 +import cherrypy
 +
 +class StringGenerator(object):
 +    @cherrypy.expose
 +    def index(self):
 +        return "Hello world!"
 +
 +    @cherrypy.expose
 +    def generate(self):
 +        return ''.join(random.sample(string.hexdigits, 8))
 +
 +if __name__ == '__main__':
 +    cherrypy.quickstart(StringGenerator())
 +</code>
python/cherrypy_notes.txt · Last modified: 2016/07/15 01:29 by mithat