Files
fastapi/docs_src/advanced_middleware/tutorial002_py310.py
2026-02-12 14:19:43 +01:00

14 lines
279 B
Python

from fastapi import FastAPI
from fastapi.middleware.trustedhost import TrustedHostMiddleware
app = FastAPI()
app.add_middleware(
TrustedHostMiddleware, allowed_hosts=["example.com", "*.example.com"]
)
@app.get("/")
async def main():
return {"message": "Hello World"}