Explore
Sign In
skills/fastapi__fastapi
1
0
Fork 0
You've already forked fastapi__fastapi
mirror of https://github.com/fastapi/fastapi.git synced 2026-09-14 13:36:21 +08:00
Code Issues Packages Projects Releases Wiki Activity
Files
02e108d1663149faac4156dd23595cbdf74287c2
fastapi__fastapi/docs_src/behind_a_proxy/tutorial002.py
T

9 lines
208 B
Python
Raw Normal View History

✨ Add support for ASGI root_path for openapi docs (#1199) * Use ASGI root_path when it is provided and openapi_prefix is empty. * Strip trailing slashes from root_path. * Please mypy. * Fix extending openapi test. * 📝 Add docs and tutorial for using root_path behind a proxy * ♻️ Refactor application root_path logic, use root_path, deprecate openapi_prefix * ✅ Add tests for Behind a Proxy with root_path * ♻️ Refactor test * 📝 Update/add docs for Sub-applications and Behind a Proxy * 📝 Update Extending OpenAPI with openapi_prefix parameter * ✅ Add test for deprecated openapi_prefix Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2020-06-11 23:53:19 +02:00
from fastapi import FastAPI, Request
app = FastAPI(root_path="/api/v1")
@app.get("/app")
def read_main(request: Request):
return {"message": "Hello World", "root_path": request.scope.get("root_path")}
Reference in New Issue Copy Permalink
Version: v1.25.5 Page: 833ms Template: 3ms
Auto
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어