feat: init project

This commit is contained in:
martsforever
2025-08-21 22:38:41 +08:00
commit 6ae03985bd
48 changed files with 7221 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
import asyncio
import json
from starlette.responses import StreamingResponse
def add_custom_stream_api_route(app):
@app.get("/my_stream")
async def custom_stream(start: int, end: int):
async def generate_numbers():
current = start
while current <= end:
yield json.dumps({"number": current}) + "\n"
await asyncio.sleep(0.2)
current += 1
return StreamingResponse(generate_numbers(), media_type="application/x-ndjson")