Replies: 1 comment 1 reply
-
from pathlib import Path
import cherrypy
PKG_DIR = Path(__file__).parent.resolve().absolute() # this file's directory
foo_conf = {
'/foo': {
'tools.staticdir.on': True,
'tools.staticdir.dir': str(PKG_DIR / 'public' / 'foo'),
'tools.staticdir.index': 'index.html',
}
}
bar_conf = {
'/bar': {
}
}
conf = {
'/': {
'request.dispatch': cherrypy.dispatch.VirtualHost(
**{
'foo.fqdn.suffix': '/foo',
'bar.fqdn.suffix': '/bar',
},
),
},
**foo_conf,
**bar_conf,
}
class Root:
@cherrypy.expose
def index(self):
return 'Main vhost'
class Bar:
@cherrypy.expose
def index(self):
return 'I am vhost: bar'
root = Root()
root.bar = Bar()
def main():
cherrypy.config.update({
'log.screen': True,
'log.access_file': str(PKG_DIR / 'logs' / 'access.log'),
'log.error_file': str(PKG_DIR / 'logs' / 'error.log'),
})
cherrypy.tree.mount(root, '/', conf)
cherrypy.engine.start()
cherrypy.engine.block()
if __name__ == '__main__':
main() |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
webknjaz
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
A quick post onto providing a cherrypy solution for hosting tow apps on different FQDNs through virtual hosts;
$PATH/logs/
$PATH/public/foo/
Beta Was this translation helpful? Give feedback.
All reactions