mirror of https://github.com/tiangolo/fastapi.git
16 lines
307 B
Python
16 lines
307 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"}
|