def start_server(config): app = web.Application(router=UrlDispatcherEx()) app['config'] = config initialize(app) web.run_app(app)
async def init_app(argv=None): app = web.Application(router=UrlDispatcherEx()) app['config'] = get_config(argv) setup_aiohttp_apispec(app=app, error_callback=my_error_handler) app.middlewares.append(validation_middleware) app.on_startup.append(init_pg) app.on_cleanup.append(close_pg) setup_routes(app) return app
key = data['key'] url_query_internal = Org.QUERY_INTERNAL + key print(url_query_internal) x = requests.get(url_query_internal) async def queryExMetaData(request): data = await request.post() key = data['key'] url_query_internal = Org.QUERY_EXTERNAL + key print(url_query_internal) x = requests.get(url_query_internal) app = web.Application(router=UrlDispatcherEx(),client_max_size=1024**2*10) cors = aiohttp_cors.setup(app) cors = aiohttp_cors.setup(app, defaults={ "*": aiohttp_cors.ResourceOptions( allow_credentials=True, expose_headers="*", allow_headers="*", ) }) app.router.add_post('/handle',handle) app.router.add_post('/push_metadata_to_eth',push_metadata_to_eth) app.router.add_post('/push_metadata_to_internal',push_metadata_to_internal) app.router.add_post('/push_metadata_to_internal_ecc',push_metadata_to_internalEcc)
async def test(request): print("..entering handler") response = web.Response( text=f"extra_stuff=[{', '.join(request.extra_stuff)}]") print("..exiting handler") return response @web.middleware async def middleware1(request, handler): print("entering middleware 1") request.extra_stuff = ['foo'] response = await handler(request) print("exiting middleware 1") return response @web.middleware async def middleware2(request, handler): print(".entering middleware 2") request.extra_stuff.append('bar') response = await handler(request) print(".exiting middleware 2") return response app = web.Application(router=UrlDispatcherEx()) app.router.add_get('/', middleware1, middleware2, test) web.run_app(app)