跳到主要内容
版本:0.17.0+

fastapi-howto

when root_path meets with doc_url

it seems easy when we read the introduction of root_path at Behind a Proxy - FastAPI however things go different when we combine this 'sugar' with no_doc_url.

I think it is because that the doc_url would all be diy by ourselves when we use the offline url settings, which deserves our special attention since I spent a bit of time suffering from it.

Finally, always remember root_path is just a 'proxy' prefix rather than the real one!

reference:

How to save uploaded files

At present, I'd love to use aiofiles to help me solve this problem.

with awiat aiofiles.open(OUT_FILE_PATH, "wb") as f:
while content := IN_FILE_OBJECT.read(1024):
await f.write(content)

reference:

How to write unit test?

using pytest.

reference:

uvicorn deployment

reference: