"""
This is based on: Tutorial - Hello World
Goals are to get vhost and /myfunc/arg1/arg2 to work.
"""
# Import CherryPy global namespace
import cherrypy
class MyRoot:
""" My Root. """
def index(self):
return "Hello world!"
index.exposed = True
class stats:
""" Stats dir providing 'static' png images. """
def index(self):
return """
Stats page
"""
index.exposed = True
class blog:
""" Sample for /blog/bla/blo, where bla and blo are args. """
def index(self,**keywords):
print keywords
return """
"""
index.exposed = True
class VHost:
def __init__(self, sitename):
self.sitename = sitename
def index(self):
return "Welcome to %s" % self.sitename
index.exposed = True
if __name__ == '__main__':
cherrypy.root = MyRoot()
cherrypy.root.stats = stats()
cherrypy.root.start = VHost("Server IP host")
cherrypy.root.blog = blog()
cherrypy.config.update({
'global': {'server.log_to_screen': True,
'server.environment': 'production',
'server.socket_port': 8033,
'server.socket_host': '192.168.1.2',
'virtual_host_filter.on': True,
'virtual_host_filter.stats.lan': '/start',
'virtual_host_filter.blog.lan': '/blog',
},
'/' : {'static_filter.on' : True,
'static_filter.root': '/path/to/www',
'static_filter.dir': '/',
},
'/start' : {'static_filter.on' : False,
'static_filter.dir': 'start',
},
'/stats' : {'static_filter.on' : True,
'static_filter.dir': 'stats',
},
'/blog' : {'static_filter.on' : False,
},
})
cherrypy.server.start()
else:
print "Doh"