From c9763181c32ec3e150f1d1b73ac1c4287cb646f5 Mon Sep 17 00:00:00 2001 From: Max Nanis Date: Sun, 13 Sep 2026 21:06:40 -0700 Subject: no html cache, crazy gitignore, manfiest parsing, html file to fstring for replacement. manually copying the manfiest file from jenkins for now --- .gitignore | 6 +++++- jb-ui/dist/.vite/manifest.json | 12 ++++++++++++ jb/main.py | 34 ++++++++++++++++++++++++++++++++-- jb/settings.py | 7 +++++++ 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 jb-ui/dist/.vite/manifest.json diff --git a/.gitignore b/.gitignore index c06043d..ded1c46 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,6 @@ __pycache__/ .Python build/ develop-eggs/ -dist/ downloads/ eggs/ .eggs/ @@ -182,3 +181,8 @@ yarn-debug.log* yarn-error.log* .vscode/* .github/* + +jb-ui/dist/* +!jb-ui/dist/.vite/ +jb-ui/dist/.vite/* +!jb-ui/dist/.vite/manifest.json \ No newline at end of file diff --git a/jb-ui/dist/.vite/manifest.json b/jb-ui/dist/.vite/manifest.json new file mode 100644 index 0000000..fe5240a --- /dev/null +++ b/jb-ui/dist/.vite/manifest.json @@ -0,0 +1,12 @@ +{ + "src/main.tsx": { + "file": "james-billings.D4Mfmnbk.js", + "name": "main", + "src": "src/main.tsx", + "isEntry": true + }, + "style.css": { + "file": "james-has-style.BW4aJU-O.css", + "src": "style.css" + } +} \ No newline at end of file diff --git a/jb/main.py b/jb/main.py index e30bb38..325bf53 100644 --- a/jb/main.py +++ b/jb/main.py @@ -7,7 +7,7 @@ from starlette.middleware.cors import CORSMiddleware from starlette.middleware.trustedhost import TrustedHostMiddleware from jb.config import settings -from jb.settings import BASE_HTML +from jb.settings import BASE_HTML, load_manifest from jb.views.auth import auth_router from jb.views.common import common_router @@ -45,9 +45,39 @@ def return_nothing() -> dict[str, Any]: @app.get("/{full_path:path}") def serve_react_app(full_path: str): + + manifest = load_manifest() + entry = manifest["src/main.tsx"] + js_file = entry["file"] + css_file = manifest["style.css"]["file"] + + html = f""" + + + + + James Billings loves you. + + + +
+ + + """ + # This serves index.html for any unmatched route # React Router will then handle the client-side routing - return HTMLResponse(BASE_HTML) + return HTMLResponse( + html, + headers={ + "Cache-Control": "no-cache, no-store, must-revalidate", + "Pragma": "no-cache", + "Expires": "0", + }, + ) def schedule_tasks(): diff --git a/jb/settings.py b/jb/settings.py index 1c02075..543a0e8 100644 --- a/jb/settings.py +++ b/jb/settings.py @@ -1,3 +1,4 @@ +import json from functools import lru_cache from os.path import abspath from os.path import dirname as pdirname @@ -16,6 +17,12 @@ BASE_DIR = pdirname(pdirname(abspath(__file__))) BASE_HTML_PATH = Path(BASE_DIR) / "templates" / "base.html" BASE_HTML = BASE_HTML_PATH.read_text() +MANIFEST_PATH = Path(BASE_DIR) / "jb-ui" / "dist/.vite/manifest.json" + + +def load_manifest(): + with open(MANIFEST_PATH) as f: + return json.load(f) class Settings(GRLBaseSettings): -- cgit v1.2.3