【发布时间】:2014-12-20 05:02:52
【问题描述】:
我想将两个cherrypy 应用程序放在同一个IP 上的不同域中。如何使用cherrypy virtualhost dispatcher为这些站点提供单独的配置文件,而不是将cherrypy Web服务器隐藏在Apache后面?
import cherrypy
from cherrypy import expose
class Root(object):
@expose
def index(self):
return "The Main Page" + \
'<br /><a href="/rs/file.txt">File from the Main app</a>'
class SecondApp(object):
@expose
def index(self):
return "Page on Subdomain" + \
'<br /><a href="/rs/file.txt">Another file from the subdomain app</a>'
def main():
cherrypy.config.update('global.conf')
conf = {"/": {"request.dispatch": cherrypy.dispatch.VirtualHost(
**{ "sub.domain.local": "/secondapp" } )
}
}
root = Root()
root.secondapp = SecondApp()
app=cherrypy.tree.mount(root, "/", conf)
app.merge('some.additional.configuration')
cherrypy.engine.start()
cherrypy.engine.block()
if __name__ == "__main__": main()
“conf”词汇定义的配置对我的域“domain.local”和“sub.domain.local”都有影响。 如何在此处为应用程序“secondapp”插入单独的配置?
【问题讨论】:
-
这是this question的副本。
标签: python configuration virtualhost cherrypy