Web version on the site: /app/ from website/static/app, precompressed Brotli/gzip
The site serves precompressed copies next to its files (the program is 19 MB, 6.3 MB in Brotli); the built program goes to website/static/app (ignored by git, taken into the image); the device page's screenshots by the site's own paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
dd1f3c6c28
commit
4ccf8099a5
4 changed files with 13 additions and 3 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -10,3 +10,6 @@
|
|||
|
||||
# A local run of the website from the repository root (website/README.md runs it from server/).
|
||||
/data-dev/
|
||||
|
||||
# The web version built for the site (apps/web/build.sh website/static/app)
|
||||
website/static/app/
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class Handler(http.server.SimpleHTTPRequestHandler):
|
|||
|
||||
def translate_path(self, path):
|
||||
path = path.split("?", 1)[0].split("#", 1)[0]
|
||||
for prefix, base in (("/app/", APP), ("/static/", STATIC)):
|
||||
for prefix, base in (("/app/", APP), ("/static/", STATIC), ("/screenshots/", STATIC / "screenshots")):
|
||||
if path.startswith(prefix):
|
||||
target = (base / path[len(prefix):]).resolve()
|
||||
if target == base or base in target.parents:
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@
|
|||
|
||||
function shots(names) {
|
||||
return el("div", { class: "shots" }, names.map(function (n) {
|
||||
return el("img", { src: "../static/screenshots/" + n, alt: "", loading: "lazy" });
|
||||
return el("img", { src: "/screenshots/" + n, alt: "", loading: "lazy" });
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -304,7 +304,14 @@ async fn main() {
|
|||
.route("/stats", get(stats))
|
||||
.route("/stats.csv", get(stats_csv))
|
||||
.route("/healthz", get(|| async { "ok" }))
|
||||
.fallback_service(ServeDir::new(static_dir).fallback(get(not_found)))
|
||||
.fallback_service(
|
||||
// Precompressed copies (`.br`, `.gz`) next to a file go to the browsers that
|
||||
// take them: the web version's program (/app/) is 23 MB, 6 MB in Brotli.
|
||||
ServeDir::new(static_dir)
|
||||
.precompressed_br()
|
||||
.precompressed_gzip()
|
||||
.fallback(get(not_found)),
|
||||
)
|
||||
.with_state(state);
|
||||
let listener = tokio::net::TcpListener::bind(("0.0.0.0", port))
|
||||
.await
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue