source: package_branches/invirt-web/cherrypy/code/main.fcgi @ 2650

Last change on this file since 2650 was 2650, checked in by broder, 15 years ago

Fix the unauthenticated web interface.

Separate the separate components of the web app by the authenticated
webapp class at /auth and the unauthenticated app at /unauth.

These are purely internal URLs, but used to allow a single CherryPy?
instance to serve both the authenticated and unauthenticated website.

  • Property svn:executable set to *
File size: 1.7 KB
Line 
1#!/usr/bin/python
2"""Main FastCGI entry point for web interface"""
3
4import cherrypy
5import os
6import sys
7from main import InvirtWeb, InvirtUnauthWeb
8
9dev = False
10base_dir = os.path.dirname(__file__)
11
12def usage():
13    print >>sys.stderr, """%s [config]
14
15Run server as FastCGI, with CherryPy config from "main.conf".
16
17With `config`, run standalone with CherryPy config from `config`.
18""" % sys.argv[0]
19    sys.exit(2)
20
21if __name__ == "__main__":
22    static_dir = os.path.join(base_dir, 'static')
23
24    if len(sys.argv) > 2:
25        usage()
26    if len(sys.argv) > 1:
27        if sys.argv[1] in ('-h', '--help'):
28            usage()
29        conf_file = sys.argv[1]
30        dev = True
31    else:
32        conf_file = os.path.join(base_dir, 'main.conf')
33
34    app_config = {
35        '/': {
36            'tools.invirtwebstate.on': True,
37            },
38        '/static': {
39            'tools.staticdir.root': static_dir,
40            'tools.staticdir.on': True,
41            'tools.staticdir.dir': static_dir,
42            }
43        }
44                   
45    authApp = cherrypy.tree.mount(InvirtWeb(),
46                                  '/auth',
47                                  app_config)
48    authApp.merge(conf_file)
49    unauthApp = cherrypy.tree.mount(InvirtUnauthWeb(),
50                                    '/unauth',
51                                    app_config)
52    unauthApp.merge(conf_file)
53    cherrypy.config.update(conf_file)
54
55    if dev:
56        cherrypy.server.quickstart()
57        cherrypy.engine.start()
58        cherrypy.engine.block()
59    else:
60        cherrypy.engine.start(blocking=False)
61        from flup.server.fcgi import WSGIServer
62        server = WSGIServer(cherrypy.tree)
63        server.run()
Note: See TracBrowser for help on using the repository browser.