Skip to content

Commit 8053869

Browse files
authored
fastapi example: fix response_class (#31)
1 parent 28d6472 commit 8053869

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

examples/fastapi/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import uvicorn
1515
from fastapi import FastAPI
16-
from fastapi.responses import HTMLResponse
16+
from fastapi.responses import HTMLResponse, StreamingResponse
1717

1818
from datastar_py.fastapi import (
1919
DatastarResponse,
@@ -59,7 +59,7 @@
5959
"""
6060

6161

62-
@app.get("/")
62+
@app.get("/", response_class=HTMLResponse)
6363
async def read_root():
6464
return HTMLResponse(HTML.replace("CURRENT_TIME", f"{datetime.isoformat(datetime.now())}"))
6565

@@ -76,7 +76,7 @@ async def time_updates():
7676
await asyncio.sleep(1)
7777

7878

79-
@app.get("/updates")
79+
@app.get("/updates", response_class=StreamingResponse)
8080
async def updates(signals: ReadSignals):
8181
# ReadSignals is a dependency that automatically loads the signals from the request
8282
print(signals)

0 commit comments

Comments
 (0)