Create services.py
Browse files- services.py +11 -0
services.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import asyncio
|
2 |
+
import json
|
3 |
+
|
4 |
+
|
5 |
+
async def event_generator():
|
6 |
+
counter = 0
|
7 |
+
while True:
|
8 |
+
data = {"message": f"Ping {counter}"}
|
9 |
+
yield f"data: {json.dumps(data)}\n\n"
|
10 |
+
counter += 1
|
11 |
+
await asyncio.sleep(1)
|