Spaces:
Sleeping
Sleeping
from fastapi import FastAPI | |
from fastapi.responses import StreamingResponse | |
import time | |
app = FastAPI() | |
def stream_text(): | |
for word in ["안녕", "세상아", "나는", "스트리밍", "API야", "!"]: | |
yield f"{word} " | |
time.sleep(0.5) | |
def stream(): | |
return StreamingResponse(stream_text(), media_type="text/plain") |