From ecfeb5927d1b58fac994d36d6a0a0fcec2ebb79c Mon Sep 17 00:00:00 2001 From: TylerCG <117808427+TylerCG@users.noreply.github.com> Date: Sat, 26 Apr 2025 09:49:15 -0400 Subject: [PATCH] test --- .dockerignore | 2 +- app/main.py | 32 +++++++++++++++------ app/templates/index.html | 61 +++++++++++++--------------------------- 3 files changed, 43 insertions(+), 52 deletions(-) diff --git a/.dockerignore b/.dockerignore index 8e98ead..c351abd 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,3 @@ __pycache__ .DS_Store -data/* \ No newline at end of file +data/ \ No newline at end of file diff --git a/app/main.py b/app/main.py index 4bc8c2f..fd40909 100644 --- a/app/main.py +++ b/app/main.py @@ -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"}) \ No newline at end of file + 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}) \ No newline at end of file diff --git a/app/templates/index.html b/app/templates/index.html index e306336..976e45a 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -2,62 +2,39 @@ - {{ title or "My Apps" }} + Show Posters -
-

{{ title or "My Apps" }}

-
- {% for app in apps %} - - {% endfor %} + {% for item in data %} +
+ {{ item['SHOW'] }} +
{{ item['SHOW'] }}
-
+ {% endfor %}