https://htpy.dev/starlette/
Usage with FastAPI:
app=FastAPI()
test_route= APIRouter(
prefix="/test",
tags=["test"],
default_response_class=HTMLResponse,
)
@test_route.get("/")
async def test():
return div["test"]
app.include_router(test_route)
if __name__ == "__main__":
uvicorn.run("test:app", host="0.0.0.0", port=9001, reload=True)
Calling localhost:9001/test/ returns error
Does not work for me as the internal FastApi Encoding does not know what to do with it (expects pydantic model). Using HTMLResponse as return works. But using a response from default response class fails for me, this would be necassary as to not delete changes in middleware or dependencies for routes that manipulate eg. the response header. Initializing HTMLReponse yourself would entail setting everything again from previous functions, every time.
Workaround is using return str(div["test"]).
https://htpy.dev/starlette/
Usage with FastAPI:
Calling localhost:9001/test/ returns error
Does not work for me as the internal FastApi Encoding does not know what to do with it (expects pydantic model). Using HTMLResponse as return works. But using a response from default response class fails for me, this would be necassary as to not delete changes in middleware or dependencies for routes that manipulate eg. the response header. Initializing HTMLReponse yourself would entail setting everything again from previous functions, every time.
Workaround is using
return str(div["test"]).