【发布时间】:2020-11-12 13:24:26
【问题描述】:
我试图在服务器端获取 FastAPI 响应的内容长度以用于日志记录。这可能吗?谢谢。
@app.get("/foo")
async def foo(background_tasks: BackgroundTasks):
data = {"foo": "foo"}
response_content_length = get_content_length()
background_tasks.add_task(log, response_content_length )
return data
【问题讨论】:
标签: python-3.x fastapi