How to use the cherrypy.tree.mount function in CherryPy

To help you get started, we’ve selected a few CherryPy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github adamhajari / spyre / tests / tests.py View on Github external
def setUpModule():
    app = TestApp()
    cherrypy.tree.mount(app.getRoot(), '/')
    cherrypy.engine.start()
github BenjV / autosub-bootstrapbill / autosub / AutoSub.py View on Github external
'tools.expires.on': True,
            'tools.expires.secs': 3600 * 24 * 7
            },
            '/mobile':{
            'tools.staticdir.on': True,
            'tools.staticdir.dir': "mobile",
            'tools.expires.on': True,
            'tools.expires.secs': 3600 * 24 * 7
            },
            '/favicon.ico':{
            'tools.staticfile.on' : True,
            'tools.staticfile.filename' : os.path.join(autosub.PATH, 'interface/media/images/favicon.ico')
            }    
        }
    
    cherrypy.tree.mount(autosub.WebServer.WebServerInit(),autosub.WEBROOT, config = conf)
    log.info("AutoSub: Starting CherryPy webserver")

    # TODO: Let CherryPy log to another log file and not to screen
    # TODO: CherryPy settings, etc...
    try:
        cherrypy.server.start()
    except Exception as error:
        log.error("AutoSub: Could not start webserver. Error is: %s" %error)
        os._exit(1)
    cherrypy.config.update({'log.screen': False,
                            'log.access_file': '',
                            'log.error_file': ''})
    cherrypy.server.wait()

    if autosub.LAUNCHBROWSER and not autosub.UPDATED:
        launchBrowser()
github RudolfCardinal / crate / crate_anon / crateweb / core / management / commands / runcpserver.py View on Github external
log.info(f"Static files will be served at URL path: "
             f"{CRATE_STATIC_URL_PATH}")
    log.info(f"CRATE will be at: {root_path}")
    log.info(f"Thread pool size: {threads}")

    static_config = {
        '/': {
            'tools.staticdir.root': settings.STATIC_ROOT,
            'tools.staticdir.debug': debug_static,
        },
        CRATE_STATIC_URL_PATH: {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': '',
        },
    }
    cherrypy.tree.mount(Missing(), '', config=static_config)
    cherrypy.tree.graft(wsgi_application, root_path)

    # noinspection PyBroadException,PyPep8
    try:
        cherrypy.engine.start()
        cherrypy.engine.block()
    except:  # 2017-03-13: shouldn't restrict to KeyboardInterrupt!
        cherrypy.engine.stop()
github girder / girder / girder / utility / server.py View on Github external
{'/':
                         {'tools.staticdir.on': True,
                          'tools.staticdir.dir': os.path.join(constants.STATIC_ROOT_DIR,
                                                              'clients/web/static'),
                          'request.show_tracebacks': appconf['/']['request.show_tracebacks'],
                          'response.headers.server': 'Girder %s' % __version__,
                          'error_page.default': _errorDefault}})

    # Mount API (special case)
    # The API is always mounted at /api AND at api relative to the Girder root
    cherrypy.tree.mount(girderWebroot.api, '/api', appconf)

    # Mount everything else in the routeTable
    for (name, route) in six.viewitems(routeTable):
        if name != constants.GIRDER_ROUTE_ID and name in pluginWebroots:
            cherrypy.tree.mount(pluginWebroots[name], route, appconf)

    if test:
        application.merge({'server': {'mode': 'testing'}})

    return application
github kovidgoyal / calibre / src / calibre / trac / donations / server.py View on Github external
def apache_start():
    cherrypy.config.update({
        'log.screen'      : False,
        #'log.error_file'  : '/tmp/donations.log',
        'environment'     : 'production',
        'show_tracebacks' : False,
        })
    cherrypy.tree.mount(Server(apache=True, root='/donations/', data_file='/var/www/calibre.kovidgoyal.net/donations.xml'),
                        '/donations', config=config())
github hulu / dripls / dripls / main.py View on Github external
},
    '/stream_ts': {
         'tools.encode.on': False,
     },
     '/': {
         'tools.encode.on': False,
     }
}
    
cherrypy.config.update({
    'log.error_file': conf.error_log,
    'log.access_file': conf.access_log,
    'log.screen': True
})

app = cherrypy.tree.mount(root, '/', app_config)
github alttch / eva3 / lib / eva / ei.py View on Github external
def start():
    if not eva.api.config.ei_enabled: return
    cherrypy.tree.mount(EI_HTTP_Root(), '/', config=cp_ei_root_config)
    cherrypy.tree.mount(EI(),
                        '/%s-ei' % eva.core.product.code,
                        config=cp_ei_config)
github mburst / burstolio / cherrypyws.py View on Github external
# Well this isn't quite as clean as I'd like so
        # feel free to suggest something more appropriate
        from django.conf import settings
        app_settings = locals().copy()
        del app_settings['self']
        settings.configure(**app_settings)
 
        self.bus.log("Mounting the Django application")
        cherrypy.tree.graft(HTTPLogger(WSGIHandler()))
 
        self.bus.log("Setting up the static directory to be served")
        # We server static files through CherryPy directly
        # bypassing entirely Django
        static_handler = cherrypy.tools.staticdir.handler(section="/", dir="static",
                                                          root=self.base_dir)
        cherrypy.tree.mount(static_handler, '/static')
github YoannQueret / ODR-EncoderManager / api.py View on Github external
# Start cherrypy
	if cli_args.daemon:
		cherrypy.process.plugins.Daemonizer(cherrypy.engine).subscribe()
	cherrypy.config.update({
		'server.socket_host': cli_args.host,
		'server.socket_port': int(cli_args.port),
		'request.show_tracebacks' : True,
		'environment': 'production',
		'tools.sessions.on': True,
		#'tools.encode.on': True,
		#'tools.encode.encoding': "utf-8",
		'log.access_file' : os.path.join(cli_args.log_dir, 'access.log'),
		'log.error_file' : os.path.join(cli_args.log_dir, 'error.log'),
		'log.screen': False,
		})
	cherrypy.tree.mount(
		API(), '/api/',
			{'/':
				{
				'request.dispatch': cherrypy.dispatch.MethodDispatcher()
				}
			}
		)
	cherrypy.tree.mount(
		root(), config={
			'/':
					{ 
					},
			'/home':
					{ 
					'tools.staticfile.on': True,
					'tools.staticfile.filename': os.path.join(cli_args.static_dir, u"home.html")
github the-virtual-brain / tvb-framework / tvb / interfaces / web / run.py View on Github external
cherrypy.tree.mount(BaseController(), "/", config=CONFIGUER)
    cherrypy.tree.mount(UserController(), "/user/", config=CONFIGUER)
    cherrypy.tree.mount(ProjectController(), "/project/", config=CONFIGUER)
    cherrypy.tree.mount(FigureController(), "/project/figure/", config=CONFIGUER)
    cherrypy.tree.mount(FlowController(), "/flow/", config=CONFIGUER)
    cherrypy.tree.mount(SettingsController(), "/settings/", config=CONFIGUER)
    cherrypy.tree.mount(HelpController(), "/help/", config=CONFIGUER)
    # cherrypy.tree.mount(BurstController(), "/burst/", config=CONFIGUER)
    cherrypy.tree.mount(SimulatorController(), "/burst/", config=CONFIGUER)
    cherrypy.tree.mount(ParameterExplorationController(), "/burst/explore/", config=CONFIGUER)
    cherrypy.tree.mount(DynamicModelController(), "/burst/dynamic/", config=CONFIGUER)
    cherrypy.tree.mount(SpatioTemporalController(), "/spatial/", config=CONFIGUER)
    cherrypy.tree.mount(RegionsModelParametersController(), "/burst/modelparameters/regions/", config=CONFIGUER)
    cherrypy.tree.mount(SurfaceModelParametersController(), "/spatial/modelparameters/surface/", config=CONFIGUER)
    cherrypy.tree.mount(RegionStimulusController(), "/spatial/stimulus/region/", config=CONFIGUER)
    cherrypy.tree.mount(SurfaceStimulusController(), "/spatial/stimulus/surface/", config=CONFIGUER)
    cherrypy.tree.mount(LocalConnectivityController(), "/spatial/localconnectivity/", config=CONFIGUER)
    cherrypy.tree.mount(NoiseConfigurationController(), "/burst/noise/", config=CONFIGUER)

    cherrypy.config.update(CONFIGUER)

    # ----------------- Register additional request handlers -----------------
    # This tool checks for MAX upload size
    cherrypy.tools.upload = Tool('on_start_resource', RequestHandler.check_upload_size)
    # This tools clean up files on disk (mainly after export)
    cherrypy.tools.cleanup = Tool('on_end_request', RequestHandler.clean_files_on_disk)
    # ----------------- End register additional request handlers ----------------

    #### HTTP Server is fired now ######  
    cherrypy.engine.start()