generated from hjess/PythonTemplateProject
added middelware
Some checks failed
Build, Push, and Deploy to Nomad / docker-nomad (push) Has been cancelled
Some checks failed
Build, Push, and Deploy to Nomad / docker-nomad (push) Has been cancelled
This commit is contained in:
5
app.py
5
app.py
@@ -6,12 +6,17 @@ import json
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from starlette.middleware.httpsredirect import HTTPSRedirectMiddleware
|
from starlette.middleware.httpsredirect import HTTPSRedirectMiddleware
|
||||||
|
from fastapi.middleware.trustedhost import TrustedHostMiddleware
|
||||||
|
from starlette.middleware.proxy_headers import ProxyHeadersMiddleware
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
# Mount static files
|
# Mount static files
|
||||||
app.mount("/static", StaticFiles(directory="static"), name="static")
|
app.mount("/static", StaticFiles(directory="static"), name="static")
|
||||||
app.add_middleware( HTTPSRedirectMiddleware )
|
app.add_middleware( HTTPSRedirectMiddleware )
|
||||||
|
app.add_middleware(ProxyHeadersMiddleware)
|
||||||
|
app.add_middleware(TrustedHostMiddleware, allowed_hosts=["*"])
|
||||||
|
|
||||||
|
|
||||||
# Templates directory
|
# Templates directory
|
||||||
templates = Jinja2Templates(directory="templates")
|
templates = Jinja2Templates(directory="templates")
|
||||||
|
|||||||
Reference in New Issue
Block a user