Beispiel #1
0
def marvcli_develop_server(port, public):
    """Run development webserver.

    ATTENTION: By default it is only served on localhost. To run it
    within a container and access it from the outside, you need to
    forward the port and tell it to listen on all IPs instead of only
    localhost.
    """
    from flask_cors import CORS
    app = create_app(push=False)
    app.site.load_for_web()
    CORS(app)

    class IPDBMiddleware(object):
        def __init__(self, app):
            self.app = app

        def __call__(self, environ, start_response):
            from ipdb import launch_ipdb_on_exception
            with launch_ipdb_on_exception():
                appiter = self.app(environ, start_response)
                for item in appiter:
                    yield item

    app.debug = True
    if IPDB:
        app.wsgi_app = IPDBMiddleware(app.wsgi_app)
        app.run(use_debugger=False,
                use_reloader=False,
                host=('0.0.0.0' if public else '127.0.0.1'),
                port=port,
                threaded=False)
    else:
        app.run(host=('0.0.0.0' if public else '127.0.0.1'),
                port=port,
                reloader_type='watchdog',
                threaded=False)
Beispiel #2
0
def marv_devserver(ipdb, port, public):
    """Run development webserver"""
    import marv._globals
    from flask_cors import CORS
    app = create_app(loglevel=logging.INFO,
                     web=True,
                     MARV_ENABLE_BG_THREADS=False)
    CORS(app)

    if ipdb:
        from ipdb import launch_ipdb_on_exception
        with launch_ipdb_on_exception():
            app.run(debug=True,
                    host=('0.0.0.0' if public else '127.0.0.1'),
                    port=port,
                    passthrough_errors=True,
                    use_debugger=False,
                    use_reloader=False)
    else:
        app.run(debug=True,
                host=('0.0.0.0' if public else '127.0.0.1'),
                port=port,
                reloader_type='watchdog',
                threaded=True)