### # python file start ### """ 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, *args): print args 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,*args): def default(self, year="", month="", day=""): print cherrypy.request.headers['Host'] print "%s-%s-%s" % (year,month,day) return """ """ #index.exposed = True default.exposed = True class VHost: def __init__(self, sitename): self.sitename = sitename def index(self): print cherrypy.request.headers['Host'] return "Welcome to %s" % self.sitename index.exposed = True import os.path conf = os.path.join(os.path.dirname(__file__), 'vhost.conf') if __name__ == '__main__': root = MyRoot() root.stats = stats() root.start = VHost("Server IP host") root.blog = blog() cherrypy.quickstart(root, config=conf) else: print "Doh" ### # python file end ### ### # config file start ### [global] server.log_to_screen = True server.environment = "experimental" server.socket_port = 8033 server.socket_host = "" tools.staticdir.root = '/path/to/www' [/start] tools.staticdir.on = False tools.staticdir.dir = 'start' [/stats] tools.staticdir.on = True tools.staticdir.dir = 'stats' [/blog] tools.staticdir.on = False [http://stats.lan:8033] virtualHostFilter.on = True, virtualHostFilter.prefix = '/stats' [http://blog.lan:8033] virtualHostFilter.on = True, virtualHostFilter.prefix = '/blog' ### # config file start ###