CherryPy: Hello world...with numbers
My first CherryPy program...
import cherrypy
class HelloWorld(object):
def index(self):
stringToDisplay = "Hello world!
"
number = 1
stringToDisplay += "The number is {0}
".format(number)
number = 14
stringToDisplay += "The number is {0}
".format(number)
stringToDisplay += ""
return stringToDisplay
index.exposed = True
cherrypy.quickstart(HelloWorld())
So, the cherrypy.quickstart line mounts an instance of a class. In this case, the HelloWorld class.
The index.exposed line allows the method to be called via the web.
The return from the index method is the HTML that will be displayed.
TODO: change the syntax highlighting css file to match the rest of the site.