Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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)
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
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)
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)
def start_http(host, port):
logger.warning(" RUNNING IN NON SSL CONTEXT ")
web.run_app(
app,
host=host,
port=config.getint("Webserver", "port"),
)
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)
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)
def run_app(port):
"""Runs the bot app locally on **port**"""
web.run_app(init_app(), port=port)
def main() -> None:
app = init_app()
app_settings = app['config']['app']
web.run_app(
app,
host=app_settings['host'],
port=app_settings['port'],
)