Ejemplo n.º 1
0
            print("Up to date")
        sys.exit(0)
    elif '--build' in sys.argv:
        # Do we need to compile?
        if not tryBuild():
            cherrypy.log("Build skipped - up to date")

    root = MainRoot()
    # Disable caching - if we don't, then between built and development
    # versions the web browser won't re-send requests.  Note that we could
    # also come up with a scheme where the URL changes when the version
    # changes.
    root._cp_config = { 'response.headers.Cache-Control': 'No-Cache' }

    if '--build' in sys.argv:
        # Running compiled version, redirect src to built version
        cherrypy.log("Using build/ rather than webapp/")
        root.src = StaticServer(_DIR + '/build')
    else:
        # Add the lib dir, rewrite src/require.js to lib/require.js
        root.lib = StaticServer(_DIR + '/../jsProject/lib')
        def serveRequire():
            return cherrypy.lib.static.serve_file(
                    root.lib._path + '/require.js')
        cherrypy.expose(serveRequire)
        root.src.require_js = serveRequire
    cherrypy.tree.mount(root, '/')
    cherrypy.engine.start()
    cherrypy.engine.block()

Ejemplo n.º 2
0
            print("Up to date")
        sys.exit(0)
    elif "--build" in sys.argv:
        # Do we need to compile?
        if not tryBuild():
            cherrypy.log("Build skipped - up to date")

    root = MainRoot()
    # Disable caching - if we don't, then between built and development
    # versions the web browser won't re-send requests.  Note that we could
    # also come up with a scheme where the URL changes when the version
    # changes.
    root._cp_config = {"response.headers.Cache-Control": "No-Cache"}

    if "--build" in sys.argv:
        # Running compiled version, redirect src to built version
        cherrypy.log("Using build/ rather than webapp/")
        root.src = StaticServer(_DIR + "/build")
    else:
        # Add the lib dir, rewrite src/require.js to lib/require.js
        root.lib = StaticServer(_DIR + "/../jsProject/lib")

        def serveRequire():
            return cherrypy.lib.static.serve_file(root.lib._path + "/require.js")

        cherrypy.expose(serveRequire)
        root.src.require_js = serveRequire
    cherrypy.tree.mount(root, "/")
    cherrypy.engine.start()
    cherrypy.engine.block()