()
| 35 | |
| 36 | |
| 37 | def _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 |
no test coverage detected
searching dependent graphs…