File: dump_asgi.py

package info (click to toggle)
python-falcon 4.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,172 kB
  • sloc: python: 33,608; javascript: 92; sh: 50; makefile: 50
file content (26 lines) | stat: -rw-r--r-- 513 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import asyncio
import time


async def _say_hi():
    print(f'[{time.time()}] Hi!')


async def app(scope, receive, send):
    await send(
        {
            'type': 'http.response.start',
            'status': 200,
            'headers': [
                [b'content-type', b'application/json'],
            ],
        }
    )
    await send(
        {
            'type': 'http.response.body',
            'body': f'[{time.time()}] Hello world!'.encode(),
        }
    )

    asyncio.create_task(_say_hi())