Initial Create
This commit is contained in:
commit
ad995affd5
0
Dockerfile
Normal file
0
Dockerfile
Normal file
BIN
app/__pycache__/main.cpython-313.pyc
Normal file
BIN
app/__pycache__/main.cpython-313.pyc
Normal file
Binary file not shown.
16
app/main.py
Normal file
16
app/main.py
Normal file
@ -0,0 +1,16 @@
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.responses import HTMLResponse
|
||||
from fastapi.templating import Jinja2Templates
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
# Mount static files if needed (e.g. CSS, JS, images)
|
||||
app.mount("/static", StaticFiles(directory="static"), name="static")
|
||||
|
||||
# Jinja2 template directory
|
||||
templates = Jinja2Templates(directory="templates")
|
||||
|
||||
@app.get("/", response_class=HTMLResponse)
|
||||
async def read_root(request: Request):
|
||||
return templates.TemplateResponse("index.html", {"request": request, "message": "Hello from FastAPI + Jinja2!"})
|
||||
9
app/templates/index.html
Normal file
9
app/templates/index.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>FastAPI with Jinja2</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>{{ message }}</h1>
|
||||
</body>
|
||||
</html>
|
||||
0
requirements.txt
Normal file
0
requirements.txt
Normal file
Loading…
x
Reference in New Issue
Block a user