Skip to content

How to use the staticdir tool combined with the VirtualHost dispatcher? #1900

Answered by webknjaz
obuno asked this question in Q&A
Discussion options

You must be logged in to vote
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:
    @ch…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@webknjaz
Comment options

Answer selected by webknjaz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants