| 1 |
from fastapi import FastAPI |
| 2 |
from fastapi.middleware.trustedhost import TrustedHostMiddleware |
| 3 |
|
| 4 |
app = FastAPI() |
| 5 |
|
| 6 |
app.add_middleware( |
| 7 |
TrustedHostMiddleware, allowed_hosts=["example.com", "*.example.com"] |
| 8 |
) |
| 9 |
|
| 10 |
|
| 11 |
@app.get("/") |
| 12 |
async def main(): |
| 13 |
return {"message": "Hello World"} |