我試圖讓虛擬主機的CherryPy 3.2.0工作乳寧對蟒蛇3:CherryPy的3.2虛擬主機調度
#!/usr/bin/env python
import cherrypy
from cherrypy import expose
class Root(object):
@expose
def index(self):
return "I am the root vhost"
class Foo(object):
@expose
def index(self):
return "I am testingdomain.com"
class Bar(object):
@expose
def index(self):
return "I am testingdomain2.com."
def main():
cherrypy.config.update({'server.socket_host': 'rootdomain.com',
'server.socket_port': 80,
})
conf = {
"/": {
"request.dispatch": cherrypy.dispatch.VirtualHost(
**{
"testingdomain.com:8000": "/foo",
"testingdomain2.com:8000": "/bar"
})
}
}
root = Root()
root.foo = Foo()
root.bar = Bar()
cherrypy.tree.mount(root, "", conf)
#cherrypy.quickstart()
cherrypy.engine.start()
cherrypy.engine.block()
if __name__ == "__main__":
main()
我有測試域入伍在/ etc/hosts中。請求時,它們被正確引導到服務器。 但我得到的唯一頁面是Root,即使我去了testingdomain.com或testingdomain2.com。
有人可以幫我嗎?
你告訴cherrypy通過'server.socket_port'選項服務於80端口,但你的虛擬主機都有端口8000 ... – SingleNegationElimination
我真的很希望,那就是問題所在。我將虛擬主機端口改爲80,但沒有任何改變。我仍然在所有測試域上獲得Root頁面。任何其他想法? – JoshuaBoshi
虛擬主機描述中是否應該有一個端口? – SingleNegationElimination