All pastes #476541 Raw Edit

CherryPy with vhost. Not working

public python v1 · immutable
·published 2007-05-08 04:36 UTC
rendered paste body
#### python file start###"""This is based on: Tutorial - Hello WorldGoals are to get vhost and /myfunc/arg1/arg2 to work."""# Import CherryPy global namespaceimport cherrypyclass MyRoot:    """ My Root. """    def index(self, *args):	print args        return "Hello world!"    index.exposed = Trueclass stats:    """ Stats dir providing 'static' png images. """    def index(self):        return """<html><head>        <title>Stats page</title></head><html><body><img src="router-bandwidth.png"><br /><img src="router-bandwidth-week.png"><br /><img src="bandwidth.png"><br /><img src="bandwidth-week.png"><br /><img src="cpu.png"><br /><img src="cpu-week.png"><br /></body></html>"""    index.exposed = Trueclass 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 = Trueclass VHost:        def __init__(self, sitename):            self.sitename = sitename        def index(self):	    print cherrypy.request.headers['Host']            return "Welcome to %s" % self.sitename        index.exposed = Trueimport os.pathconf = 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 = Trueserver.environment = "experimental"server.socket_port = 8033server.socket_host = "<lan.ip>"tools.staticdir.root = '/path/to/www'[/start]tools.staticdir.on = Falsetools.staticdir.dir = 'start'[/stats]tools.staticdir.on = Truetools.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###