MCPcopy
hub / github.com/aio-libs/aiohttp / _create_example_app

Function _create_example_app

tests/test_test_utils.py:37–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35
36
37def _create_example_app():
38 async def hello(request):
39 return web.Response(body=_hello_world_bytes)
40
41 async def websocket_handler(request):
42
43 ws = web.WebSocketResponse()
44 await ws.prepare(request)
45 msg = await ws.receive()
46 if msg.type == aiohttp.WSMsgType.TEXT:
47 if msg.data == "close":
48 await ws.close()
49 else:
50 await ws.send_str(msg.data + "/answer")
51
52 return ws
53
54 async def cookie_handler(request):
55 resp = web.Response(body=_hello_world_bytes)
56 resp.set_cookie("cookie", "val")
57 return resp
58
59 app = web.Application()
60 app.router.add_route("*", "/", hello)
61 app.router.add_route("*", "/websocket", websocket_handler)
62 app.router.add_route("*", "/cookie", cookie_handler)
63 return app
64
65
66# these exist to test the pytest scenario

Callers 9

appFunction · 0.85
test_with_client_failsFunction · 0.85
get_appMethod · 0.85
test_test_client_propsFunction · 0.85

Calls 1

add_routeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…