Esempio n. 1
0
def create_app(site, hostname='127.0.0.1', port=5000, *args, **kwargs):
    from common.database import DATABASE

    wsgi = dispatcher.wsgi(site, hostname, port, **kwargs)

    @wsgi.pre_response
    def db_connect(request):
        restart = False
        try:
            DATABASE.connect()
        except OperationalError:
            restart = True

        if restart:
            try:
                DATABASE.close()
                DATABASE.connect()
            except Exception:
                pass

    @wsgi.post_response
    def db_close(request, response):
        try:
            DATABASE.close()
        except Exception:
            pass

    @wsgi.post_exception
    def db_close_exception(request, error):
        try:
            DATABASE.close()
        except Exception:
            pass

    return wsgi
Esempio n. 2
0
def create(site='./website', hostname='127.0.0.1', port=3100):
    wsgi = dispatcher.wsgi(
        site,
        hostname,
        port,
    )
    wsgi.global_events.on_pre_response(connect)
    wsgi.global_events.on_post_response(close)
    return wsgi
Esempio n. 3
0
def runserver(site, hostname, port, reloader, debugger, evalex, threaded,
              processes):

    basedir = os.path.abspath(os.getcwd()) + site
    """Start a new development server."""
    app = dispatcher.wsgi(basedir,
                          hostname,
                          port,
                          use_reloader=reloader,
                          use_debugger=debugger,
                          use_evalex=evalex,
                          threaded=threaded,
                          processes=processes)  # , ssl_context=(crt, key))

    app.serve()
Esempio n. 4
0
def runserver(site, hostname, port, reloader, debugger, evalex, threaded,
              processes, extension):
    basedir = os.path.abspath(os.getcwd()) + site

    before_reload()
    after_reload()
    deprecation_warning(extension)
    """Start a new development server."""
    app = dispatcher.wsgi(basedir,
                          hostname,
                          port,
                          use_reloader=reloader,
                          use_debugger=debugger,
                          use_evalex=evalex,
                          threaded=threaded,
                          processes=processes,
                          extension=extension)

    app.serve()
Esempio n. 5
0
from simplerr import dispatcher

site = '/Users/harvey/dev/simplerr.com/examples/01.kitchen_sink/'
hostname = 'localhost'
port = 80

wsgi = dispatcher.wsgi(site, hostname, port)
application = wsgi.make_app_prod()