generated from hjess/PythonTemplateProject
[main] Static folder
All checks were successful
Build, Push, and Deploy to Nomad / docker-nomad (push) Successful in 33s
All checks were successful
Build, Push, and Deploy to Nomad / docker-nomad (push) Successful in 33s
This commit is contained in:
BIN
__pycache__/app.cpython-312.pyc
Normal file
BIN
__pycache__/app.cpython-312.pyc
Normal file
Binary file not shown.
15
app.py
15
app.py
@@ -11,25 +11,12 @@ from starlette.middleware.base import BaseHTTPMiddleware
|
|||||||
from starlette.requests import Request
|
from starlette.requests import Request
|
||||||
from fastapi.middleware.trustedhost import TrustedHostMiddleware
|
from fastapi.middleware.trustedhost import TrustedHostMiddleware
|
||||||
|
|
||||||
class ProxyHeadersMiddleware(BaseHTTPMiddleware):
|
|
||||||
async def dispatch(self, request: Request, call_next):
|
|
||||||
proto = request.headers.get("X-Forwarded-Proto", "http")
|
|
||||||
host = request.headers.get("X-Forwarded-Host", request.headers.get("Host"))
|
|
||||||
|
|
||||||
# Update request scheme and host for correct URL generation
|
|
||||||
request.scope["scheme"] = proto
|
|
||||||
if host:
|
|
||||||
request.scope["server"] = (host.split(":")[0], request.scope["server"][1])
|
|
||||||
|
|
||||||
response = await call_next(request)
|
|
||||||
return response
|
|
||||||
|
|
||||||
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(ProxyHeadersMiddleware)
|
|
||||||
app.add_middleware(TrustedHostMiddleware, allowed_hosts=["lifefaq.nomad.i80.dk", "lifefaq.i80.dk","localhost"])
|
|
||||||
|
|
||||||
# Templates directory
|
# Templates directory
|
||||||
templates = Jinja2Templates(directory="templates")
|
templates = Jinja2Templates(directory="templates")
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
<title>{% block title %}PortugalFAQ{% endblock %}</title>
|
<title>{% block title %}PortugalFAQ{% endblock %}</title>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
|
||||||
<link rel="stylesheet" href="{{ url_for('static', path='css/main.css') }}">
|
<!-- <link rel="stylesheet" href="{{ url_for('static', path='css/main.css') }}"> -->
|
||||||
|
<link rel="stylesheet" href="/static/css/main.css">
|
||||||
</head>
|
</head>
|
||||||
<body class="is-preload">
|
<body class="is-preload">
|
||||||
<!-- Wrapper -->
|
<!-- Wrapper -->
|
||||||
@@ -39,10 +40,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Scripts -->
|
<!-- Scripts -->
|
||||||
<script src="{{ url_for('static', path='js/jquery.min.js') }}"></script>
|
<script src="/static/js/jquery.min.js"></script>
|
||||||
<script src="{{ url_for('static', path='js/browser.min.js') }}"></script>
|
<script src="/static/js/browser.min.js"></script>
|
||||||
<script src="{{ url_for('static', path='js/breakpoints.min.js') }}"></script>
|
<script src="/static/js/breakpoints.min.js"></script>
|
||||||
<script src="{{ url_for('static', path='js/util.js') }}"></script>
|
<script src="/static/js/util.js"></script>
|
||||||
<script src="{{ url_for('static', path='js/main.js') }}"></script>
|
<script src="/static/js/main.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user