Changeset 2660 for package_branches


Ignore:
Timestamp:
Dec 20, 2009, 9:43:41 PM (15 years ago)
Author:
broder
Message:

Basic CherryPy? FastCGI handler

File:
1 edited

Legend:

Unmodified
Added
Removed
  • package_branches/invirt-web/cherrypy-rebased/code/main.fcgi

    r1318 r2660  
    11#!/usr/bin/python
    2 import main
    3 main.main()
     2"""Main FastCGI entry point for web interface"""
     3
     4import cherrypy
     5import os
     6import sys
     7from main import InvirtWeb
     8
     9dev = False
     10base_dir = os.path.dirname(__file__)
     11
     12if __name__=="__main__":
     13    if len(sys.argv) > 1:
     14        conf_file = sys.argv[1]
     15        dev = True
     16    else:
     17        conf_file = os.path.join(base_dir, 'main.conf')
     18    app = cherrypy.tree.mount(InvirtWeb(), '/' if dev else '/main.fcgi')
     19    app.merge(conf_file)
     20    cherrypy.config.update(conf_file)
     21
     22    if dev:
     23        cherrypy.server.quickstart()
     24        cherrypy.engine.start()
     25        cherrypy.engine.block()
     26    else:
     27        cherrypy.engine.start(blocking=False)
     28        from flup.server.fcgi import WSGIServer
     29        server = WSGIServer(app)
     30        server.run()
Note: See TracChangeset for help on using the changeset viewer.