Exemplo n.º 1
0
def runserver(**config):
    """
    Run a development server for an aiohttp apps.
    Takes one argument "app-path" which should be a path to either a directory containing a recognized default file
    ("app.py" or "main.py") or to a specific file. Defaults to the environment variable "AIO_APP_PATH" or ".".
    The app path is run directly, see the "--app-factory" option for details on how an app is loaded from a python
    module.
    """
    os.environ.setdefault('AIOHTTP_SETTINGS_MODULE', 'config.settings.dev')

    active_config = {k: v for k, v in config.items() if v is not None}
    setup_logging(config['verbose'])
    try:
        run_app(*_runserver(**active_config))
    except AiohttpDevException as e:
        if config['verbose']:
            tb = click.style(traceback.format_exc().strip('\n'), fg='white', dim=True)
            main_logger.warning('AiohttpDevException traceback:\n%s', tb)
        main_logger.error('Error: %s', e)
        sys.exit(2)
Exemplo n.º 2
0
def test_run_app(loop, unused_port):
    app = Application()
    obersver = mock.MagicMock()
    port = unused_port()
    Process(target=kill_parent_soon, args=(os.getpid(), )).start()
    run_app(app, obersver, port, loop)
Exemplo n.º 3
0
def test_run_app(loop, aiohttp_unused_port):
    app = Application()
    port = aiohttp_unused_port()
    Process(target=kill_parent_soon, args=(os.getpid(),)).start()
    run_app(app, port, loop, AccessLogger)