aboutsummaryrefslogtreecommitdiff
path: root/kennel/main.py
diff options
context:
space:
mode:
authorB Wu <bxwu@amazon.com>2024-08-07 20:11:52 -0700
committerB Wu <bxwu@amazon.com>2024-08-07 20:11:52 -0700
commit514b0338844334aa4aaf332c6e29efb6a1aadaa6 (patch)
tree74cccb983214a43688c6422bc2459c7fef73f194 /kennel/main.py
parent6f03348e5aac33118840324a96e9321dca483b9f (diff)
downloadkennel.hatecomputers.club-514b0338844334aa4aaf332c6e29efb6a1aadaa6.tar.gz
kennel.hatecomputers.club-514b0338844334aa4aaf332c6e29efb6a1aadaa6.zip
feat: add static and template rendering
Diffstat (limited to 'kennel/main.py')
-rw-r--r--kennel/main.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/kennel/main.py b/kennel/main.py
index f0eaaca..3cca2c0 100644
--- a/kennel/main.py
+++ b/kennel/main.py
@@ -2,6 +2,8 @@ import uuid
import structlog
from fastapi import FastAPI, Request, Response
+from fastapi.staticfiles import StaticFiles
+from fastapi.templating import Jinja2Templates
app = FastAPI()
logger = structlog.get_logger()
@@ -33,6 +35,8 @@ async def logger_middleware(request: Request, call_next):
return response
+templates = Jinja2Templates(directory="templates")
+
@app.get("/healthcheck")
async def healthcheck():
@@ -40,6 +44,10 @@ async def healthcheck():
@app.get("/")
-async def read_main():
- logger.info("In root path")
- return {"msg": "Hello World"}
+async def read_main(request: Request):
+ return templates.TemplateResponse(
+ request=request, name="index.html"
+ )
+
+app.mount("/static", StaticFiles(directory = "static"), name = "static")
+