How to use the aiohttp.web.run_app function in aiohttp

To help you get started, we’ve selected a few aiohttp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / BotBuilder-Samples / samples / python / 17.multilingual-bot / app.py View on Github external
activity = Activity().deserialize(body)
    auth_header = req.headers["Authorization"] if "Authorization" in req.headers else ""

    response = await ADAPTER.process_activity(activity, auth_header, BOT.on_turn)
    if response:
        return json_response(data=response.body, status=response.status)
    return Response(status=HTTPStatus.OK)


APP = web.Application(middlewares=[aiohttp_error_middleware])
APP.router.add_post("/api/messages", messages)

if __name__ == "__main__":
    try:
        web.run_app(APP, host="localhost", port=CONFIG.PORT)
    except Exception as error:
        raise error
github MrNaif2018 / bitcart / daemons / ltc.py View on Github external
from base import BaseDaemon


class LTCDaemon(BaseDaemon):
    name = "LTC"
    electrum = electrum_ltc
    DEFAULT_PORT = 5001


daemon = LTCDaemon()

app = web.Application()
app.router.add_post("/", daemon.handle_request)
app.on_startup.append(daemon.on_startup)
app.on_shutdown.append(daemon.on_shutdown)
web.run_app(app, host=daemon.HOST, port=daemon.PORT)
github microsoft / BotBuilder-Samples / samples / python / 81.skills-skilldialog / dialog-skill-bot / app.py View on Github external
activity = Activity().deserialize(body)
    auth_header = req.headers["Authorization"] if "Authorization" in req.headers else ""

    invoke_response = await ADAPTER.process_activity(activity, auth_header, BOT.on_turn)
    if invoke_response:
        return json_response(data=invoke_response.body, status=invoke_response.status)
    return Response(status=HTTPStatus.OK)


APP = web.Application(middlewares=[aiohttp_error_middleware])
APP.router.add_post("/api/messages", messages)

if __name__ == "__main__":
    try:
        web.run_app(APP, host="localhost", port=CONFIG.PORT)
    except Exception as error:
        raise error
github mikeyy / nonoCAPTCHA / examples / aiohttp_single_loop.py View on Github external
async def start_background_tasks(app):
    app["dispatch"] = app.loop.create_task(load_proxies())


async def cleanup_background_tasks(app):
    app["dispatch"].cancel()
    await app["dispatch"]


app.router.add_get("/", get_solution)
app.on_startup.append(start_background_tasks)
app.on_cleanup.append(cleanup_background_tasks)

if __name__ == "__main__":
    web.run_app(app, host="0.0.0.0", port=5000)
github hjlarry / zhihulive / run.py View on Github external
def webserver():
    click.echo('Start web server')
    threading.Thread(target=media_server, args=()).start()
    app.router.add_static('/static', 'web/static')
    web.run_app(app, host=config.WEB_SERVER_HOST, port=config.WEB_SERVER_PORT)
github Kruptein / PlanarAlly / server / planarserver.py View on Github external
def start_http(host, port):
    logger.warning(" RUNNING IN NON SSL CONTEXT ")
    web.run_app(
        app,
        host=host,
        port=config.getint("Webserver", "port"),
    )
github hail-is / hail / ci / ci / ci.py View on Github external
def run():
    app = web.Application()
    setup_aiohttp_jinja2(app, 'ci')
    setup_aiohttp_session(app)

    app.on_startup.append(on_startup)
    app.on_cleanup.append(on_cleanup)

    setup_common_static_routes(routes)
    app.add_routes(routes)

    web.run_app(deploy_config.prefix_application(app, 'ci'), host='0.0.0.0', port=5000)
github hyperledger / aries-staticagent-python / examples / preprocessors.py View on Github external
async def handle(request):
        """aiohttp handle POST."""
        response = []
        with conn.session(response.append) as session:
            await conn.handle(await request.read(), session)

        if response:
            return web.Response(text=response.pop())

        raise web.HTTPAccepted()

    app = web.Application()
    app.add_routes([web.post('/', handle)])

    web.run_app(app, port=args.port)
github bioconda / bioconda-utils / bioconda_utils / bot.py View on Github external
def run_app(port):
    """Runs the bot app locally on **port**"""
    web.run_app(init_app(), port=port)
github aio-libs / create-aio-app / create_aio_app / template / {{cookiecutter.project_name}} / {{cookiecutter.project_name}} / __main__.py View on Github external
def main() -> None:
    app = init_app()
    app_settings = app['config']['app']

    web.run_app(
        app,
        host=app_settings['host'],
        port=app_settings['port'],
    )