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/tutorial004.py
T

16 lines
437 B
Python
Raw Normal View History

✨ Auto-generate OpenAPI servers from root_path (#1596) * root_path included in servers object instead of path prefix * ♻️ Refactor implementation of auto-including root_path in OpenAPI servers * 📝 Update docs and examples for Behind a Proxy, including servers * 📝 Update Extending OpenAPI as openapi_prefix is no longer needed * ✅ Add extra tests for root_path in servers and root_path_in_servers=False * 🍱 Update security docs images with relative token URL * 📝 Update security docs with relative token URL * 📝 Update example sources with relative token URLs * ✅ Update tests with relative tokens Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2020-07-10 13:28:18 -04:00
from fastapi import FastAPI, Request
app = FastAPI(
servers=[
{"url": "https://stag.example.com", "description": "Staging environment"},
{"url": "https://prod.example.com", "description": "Production environment"},
],
root_path="/api/v1",
root_path_in_servers=False,
)
@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: 451ms 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 Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어