diff options
| author | Max Nanis | 2026-09-13 21:06:40 -0700 |
|---|---|---|
| committer | Max Nanis | 2026-09-13 21:06:40 -0700 |
| commit | c9763181c32ec3e150f1d1b73ac1c4287cb646f5 (patch) | |
| tree | ba5e2b16ff8daf97870f179e6a2cd1376d2eebb4 /jb | |
| parent | aef85c15f867b218ed108a52c40a761cf46750bb (diff) | |
| download | amt-jb-c9763181c32ec3e150f1d1b73ac1c4287cb646f5.tar.gz amt-jb-c9763181c32ec3e150f1d1b73ac1c4287cb646f5.zip | |
no html cache, crazy gitignore, manfiest parsing, html file to fstring for replacement.
manually copying the manfiest file from jenkins for now
Diffstat (limited to 'jb')
| -rw-r--r-- | jb/main.py | 34 | ||||
| -rw-r--r-- | jb/settings.py | 7 |
2 files changed, 39 insertions, 2 deletions
@@ -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"""<!doctype html> + <html lang="en-US"> + <head> + <meta charset="utf-8"> + <meta name="viewport" + content="width=device-width, initial-scale=1.0, height=device-height, minimum-scale=1.0, user-scalable=1"> + <title>James Billings loves you.</title> + <link rel="stylesheet" + href="https://cdn.jamesbillings67.com/{css_file}" + type="text/css"> + </head> + <body> + <div id="root"></div> + <script src="https://cdn.jamesbillings67.com/{js_file}"></script> + </body> + </html>""" + # 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): |
