This commit is contained in:
TylerCG 2025-04-26 09:49:15 -04:00
parent ec782c4ce1
commit ecfeb5927d
3 changed files with 43 additions and 52 deletions

View File

@ -1,3 +1,3 @@
__pycache__
.DS_Store
data/*
data/

View File

@ -1,7 +1,7 @@
from fastapi import FastAPI, Request, Form
from fastapi.responses import HTMLResponse, JSONResponse
from fastapi.templating import Jinja2Templates
# from fastapi.staticfiles import StaticFiles
from fastapi.staticfiles import StaticFiles
# from fastapi.concurrency import run_in_threadpool
from pathlib import Path
from functools import partial
@ -11,6 +11,8 @@ from typing import Optional
app = FastAPI()
# app.mount("/static", StaticFiles(directory="/app/app/static"), name="static")
app.mount("/data", StaticFiles(directory="/data"), name="data")
templates = Jinja2Templates(directory="templates")
loop = asyncio.get_running_loop()
@ -69,12 +71,24 @@ async def ydl(url: str, location: str):
return JSONResponse(status_code=500, content={"status": "error", "message": str(e)})
# html
@app.get("/", include_in_schema=False, response_class=HTMLResponse)
# @app.get("/", include_in_schema=False, response_class=HTMLResponse)
# 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"})
# JSON cache
cached_data = None
@app.get("/", response_class=HTMLResponse)
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"})
global cached_data
if cached_data is None:
with open('/data/dropout.json') as f:
cached_data = json.load(f)
return templates.TemplateResponse("index.html", {"request": request, "data": cached_data})

View File

@ -2,62 +2,39 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{ title or "My Apps" }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Show Posters</title>
<style>
body {
margin: 0;
font-family: Arial, sans-serif;
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #f4f4f4;
}
.container {
.tile {
width: 400px;
margin: 10px;
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: 1px solid #ddd;
border-radius: 8px;
padding: 20px;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
transition: transform 0.2s ease;
cursor: pointer;
overflow: hidden;
}
.app-card:hover {
transform: scale(1.05);
.tile img {
width: 100%;
height: auto;
}
.tile .title {
padding: 10px;
background-color: #f4f4f4;
}
</style>
</head>
<body>
<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 %}
{% for item in data %}
<div class="tile">
<img src="{{ item['POSTER'] }}" alt="{{ item['SHOW'] }}">
<div class="title">{{ item['SHOW'] }}</div>
</div>
</div>
{% endfor %}
</body>
</html>