mirror of https://github.com/tiangolo/fastapi.git
14 lines
298 B
Python
14 lines
298 B
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.trustedhost import TrustedHostMiddleware
|
|
|
|
app = FastAPI()
|
|
|
|
app.add_middleware(
|
|
TrustedHostMiddleware, allowed_hosts=["example.com", "*.example.com"], www_redirect=True
|
|
)
|
|
|
|
|
|
@app.get("/")
|
|
async def main():
|
|
return {"message": "Hello World"}
|