Source

silk-deployment / silk / devserver.py

import os
import sys
import cherrypy

import silk.lib

role = silk.lib.get_role()
root = silk.lib.get_site_root(os.getcwd())
config = silk.lib.get_config(root, role)

if config.get('static_dirs'):
    for static_dir in config['static_dirs']:
        # Mount each of our static dirs as its own app in the cherrypy tree.
        # Each static_dir is a dict with url_path and system_path keys
        url_path = static_dir['url_path'].rstrip('/')
        sys_path = os.path.join(root, static_dir['system_path'])
        cherry_conf = {'/': {'tools.staticdir.on': True,
                             'tools.staticdir.dir': sys_path,}}
        cherrypy.tree.mount(None, script_name=url_path, config=cherry_conf)

#mount the wsgi app
wsgi_app = cherrypy.lib.attributes(config['wsgi_app'].replace(':', '.'))
cherrypy.tree.graft(wsgi_app, '')

sys.path.append(root)
os.chdir(root)
app = cherrypy.tree
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.