update
This commit is contained in:
parent
90ee78dcf1
commit
9b2151f7a9
Binary file not shown.
10
app/main.py
10
app/main.py
@ -41,5 +41,11 @@ async def ydl(url: str, location: str):
|
||||
|
||||
# html
|
||||
@app.get("/", response_class=HTMLResponse)
|
||||
async def read_root(request: Request):
|
||||
return templates.TemplateResponse("index.html", {"request": request, "message": "Hello from FastAPI + Jinja2!"})
|
||||
async def index(request: Request):
|
||||
apps = [
|
||||
{"name": "Notes", "url": "/notes"},
|
||||
{"name": "Todo List", "url": "/todos"},
|
||||
{"name": "Weather", "url": "/weather"},
|
||||
# Add more apps here
|
||||
]
|
||||
return templates.TemplateResponse("index.html", {"request": request, "apps": apps, "title": "Welcome to My App Hub"})
|
||||
@ -1,9 +1,63 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>FastAPI with Jinja2</title>
|
||||
<meta charset="UTF-8">
|
||||
<title>{{ title or "My Apps" }}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: Arial, sans-serif;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
background-color: #f4f4f4;
|
||||
}
|
||||
|
||||
.container {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-bottom: 30px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.apps-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||
gap: 20px;
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.app-card {
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
||||
transition: transform 0.2s ease;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.app-card:hover {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>{{ message }}</h1>
|
||||
<div class="container">
|
||||
<h1>{{ title or "My Apps" }}</h1>
|
||||
<div class="apps-grid">
|
||||
{% for app in apps %}
|
||||
<div class="app-card">
|
||||
<a href="{{ app.url }}" style="text-decoration: none; color: inherit;">
|
||||
{{ app.name }}
|
||||
</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user