974690132e
New layout:
src/script/app/ Python package (was app/)
src/assets/img/ SVGs (was static/*.svg)
src/assets/css/ stylesheet (was static/style.css)
src/templates/ HTML templates (was templates/)
illustration/ README screenshot (was screenshots/), kept at
the repo root since it's a doc asset, not
something the app serves
main.py, jobs/, VERSION, docker/ unchanged locations
main.py stays at the repo root as the entry point (matches how
Docker and local runs already invoke it) and prepends src/script to
sys.path before importing app, rather than moving into src/script/
itself and needing every entry point updated to match.
config.py's path constants are recomputed for app/config.py's new
depth (src/script/app/), with SRC_DIR and REPO_ROOT resolved
explicitly rather than a single ambiguous BASE_DIR, since "templates
and assets live under src/" and "jobs and VERSION live at the repo
root" are no longer the same directory. Flask's static_folder now
points at src/assets, which serves img/ and css/ under it at
whatever URL prefix Flask derives from the folder name (/assets, not
/static); templates already reference assets via the "static"
endpoint name through url_for, so this needed the url_for() calls'
filename argument updated with the img/ or css/ prefix, not a
hardcoded URL change.
Docker copies src/ into the image preserving this same internal
structure, so the path arithmetic in config.py resolves identically
in both a local checkout and the container, no --chdir or other
container-specific path handling needed.
Verified end to end after the move: local Flask dev server, a full
Docker rebuild, and a real HTTP conversion request through the
running container (TIFF HDR pipeline, numpy/tifffile imports
included) all succeed.
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Instagram HDR Assembler — Web Front
|
|
------------------------------------
|
|
Flask front end for assembling Instagram-compliant HDR JPEGs (gain map
|
|
injection adapted from kostis-kounadis/instagram-hdr-assembler — see
|
|
LICENSE). Gives you a browser form instead of a terminal, and
|
|
surfaces the assembly report (including the "GainMapMin is negative"
|
|
warning) on a results page.
|
|
|
|
This file is just the entry point — see src/script/app/ for the app itself:
|
|
src/script/app/config.py constants
|
|
src/script/app/jobs.py in-memory job registry + heartbeat/reaper
|
|
src/script/app/validation.py upload + Instagram resolution checks
|
|
src/script/app/assembler.py gain-map assembly pipeline
|
|
src/script/app/routes.py Flask routes
|
|
|
|
Run directly: python3 main.py
|
|
Run in Docker: see Dockerfile (gunicorn main:app)
|
|
"""
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent / "src" / "script"))
|
|
|
|
from app import create_app
|
|
from app.assembler import check_dependencies
|
|
|
|
app = create_app()
|
|
|
|
if __name__ == "__main__":
|
|
missing = check_dependencies()
|
|
if missing:
|
|
print(f"ERROR: missing required tools on PATH: {', '.join(missing)}", file=sys.stderr)
|
|
sys.exit(1)
|
|
port = int(os.environ.get("PORT", 5000))
|
|
app.run(host="0.0.0.0", port=port, debug=False)
|