Source

CherryPy Recipes / deployment / fapws_ / __init__.py

Full commit
# -*- coding: utf-8 -*-
__doc__ = """ Demonstrates on how to run
a CherryPy application within a fapws3 WSGI server.

It requires fapws3 http://www.fapws.org/
"""
import cherrypy

class Root(object):
    @cherrypy.expose
    def index(self):
        return "Hello world"

if __name__=="__main__":
    import fapws._evwsgi as evwsgi
    from fapws import base

    # Mount the application so that it
    # served by the CherryPy application server
    # The returned app is a WSGI application
    app = cherrypy.tree.mount(Root())

    # Siince we are using the fapws3 WSGI server
    # we prevent the CherryPy HTTP server
    # from being started
    cherrypy.server.unsubscribe()

    # Finally we run the CherryPy application
    # server
    cherrypy.engine.start()
    
    evwsgi.start("0.0.0.0", "8090")
    evwsgi.set_base_module(base)
    
    evwsgi.wsgi_cb(("/", app))

    evwsgi.set_debug(0)    
    evwsgi.run()