From 974690132e0fca8f7d6e4944ef21a17e4b34517d Mon Sep 17 00:00:00 2001 From: Djeex Date: Sat, 1 Aug 2026 15:26:18 +0200 Subject: [PATCH] Reorganize into src/ with script/assets/templates, illustration/ at root 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. --- README.md | 4 ++-- docker/Dockerfile | 4 +--- {screenshots => illustration}/insta-hdr-1.png | Bin main.py | 15 +++++++++------ {static => src/assets/css}/style.css | 0 {static => src/assets/img}/gitea.svg | 0 {static => src/assets/img}/github.svg | 0 {app => src/script/app}/__init__.py | 6 +++--- {app => src/script/app}/assembler.py | 0 {app => src/script/app}/config.py | 11 ++++++++--- {app => src/script/app}/jobs.py | 0 {app => src/script/app}/routes.py | 0 {app => src/script/app}/validation.py | 0 {templates => src/templates}/index.html | 6 +++--- {templates => src/templates}/result.html | 6 +++--- 15 files changed, 29 insertions(+), 23 deletions(-) rename {screenshots => illustration}/insta-hdr-1.png (100%) rename {static => src/assets/css}/style.css (100%) rename {static => src/assets/img}/gitea.svg (100%) rename {static => src/assets/img}/github.svg (100%) rename {app => src/script/app}/__init__.py (73%) rename {app => src/script/app}/assembler.py (100%) rename {app => src/script/app}/config.py (76%) rename {app => src/script/app}/jobs.py (100%) rename {app => src/script/app}/routes.py (100%) rename {app => src/script/app}/validation.py (100%) rename {templates => src/templates}/index.html (96%) rename {templates => src/templates}/result.html (94%) diff --git a/README.md b/README.md index 14673cb..4aa6fac 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,14 @@ A small web front end for assembling Instagram-compatible HDR JPEGs (gain map) from an SDR export and an HDR export out of Lightroom or Camera Raw. -The gain-map assembly logic ([app/assembler.py](app/assembler.py)) is +The gain-map assembly logic ([src/script/app/assembler.py](src/script/app/assembler.py)) is adapted from [kostis-kounadis/instagram-hdr-assembler](https://github.com/kostis-kounadis/instagram-hdr-assembler), itself based on the reverse-engineering work of [karachungen/instagram-hdr-converter](https://github.com/karachungen/instagram-hdr-converter). Original MIT license kept in [LICENSE](LICENSE). -![Instagram HDR Assembler screenshot](screenshots/insta-hdr-1.png) +![Instagram HDR Assembler screenshot](illustration/insta-hdr-1.png) ## How it works diff --git a/docker/Dockerfile b/docker/Dockerfile index 8f725d2..d325917 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -27,9 +27,7 @@ COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY main.py . -COPY app/ app/ -COPY templates/ templates/ -COPY static/ static/ +COPY src/ src/ COPY LICENSE VERSION ./ COPY docker/entrypoint.sh /app/entrypoint.sh RUN chmod +x /app/entrypoint.sh diff --git a/screenshots/insta-hdr-1.png b/illustration/insta-hdr-1.png similarity index 100% rename from screenshots/insta-hdr-1.png rename to illustration/insta-hdr-1.png diff --git a/main.py b/main.py index 07b91e4..da83164 100644 --- a/main.py +++ b/main.py @@ -8,18 +8,21 @@ 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 app/ for the app itself: - app/config.py constants - app/jobs.py in-memory job registry + heartbeat/reaper - app/validation.py upload + Instagram resolution checks - app/assembler.py gain-map assembly pipeline - app/routes.py Flask routes +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 diff --git a/static/style.css b/src/assets/css/style.css similarity index 100% rename from static/style.css rename to src/assets/css/style.css diff --git a/static/gitea.svg b/src/assets/img/gitea.svg similarity index 100% rename from static/gitea.svg rename to src/assets/img/gitea.svg diff --git a/static/github.svg b/src/assets/img/github.svg similarity index 100% rename from static/github.svg rename to src/assets/img/github.svg diff --git a/app/__init__.py b/src/script/app/__init__.py similarity index 73% rename from app/__init__.py rename to src/script/app/__init__.py index 121c9ee..cd0238b 100644 --- a/app/__init__.py +++ b/src/script/app/__init__.py @@ -2,15 +2,15 @@ from flask import Flask from . import jobs -from .config import BASE_DIR, MAX_CONTENT_LENGTH, VERSION +from .config import ASSETS_DIR, MAX_CONTENT_LENGTH, TEMPLATES_DIR, VERSION from .routes import register_routes def create_app() -> Flask: app = Flask( __name__, - template_folder=str(BASE_DIR / "templates"), - static_folder=str(BASE_DIR / "static"), + template_folder=str(TEMPLATES_DIR), + static_folder=str(ASSETS_DIR), ) app.config["MAX_CONTENT_LENGTH"] = MAX_CONTENT_LENGTH diff --git a/app/assembler.py b/src/script/app/assembler.py similarity index 100% rename from app/assembler.py rename to src/script/app/assembler.py diff --git a/app/config.py b/src/script/app/config.py similarity index 76% rename from app/config.py rename to src/script/app/config.py index 9d84aa5..0367f9f 100644 --- a/app/config.py +++ b/src/script/app/config.py @@ -1,9 +1,14 @@ """Shared constants for the HDR-to-Instagram web front.""" from pathlib import Path -BASE_DIR = Path(__file__).resolve().parent.parent -JOBS_DIR = BASE_DIR / "jobs" -VERSION = (BASE_DIR / "VERSION").read_text().strip() +# This file lives at /src/script/app/config.py. +SRC_DIR = Path(__file__).resolve().parent.parent.parent +REPO_ROOT = SRC_DIR.parent + +TEMPLATES_DIR = SRC_DIR / "templates" +ASSETS_DIR = SRC_DIR / "assets" +JOBS_DIR = REPO_ROOT / "jobs" +VERSION = (REPO_ROOT / "VERSION").read_text().strip() ALLOWED_SDR_EXT = {".jpg", ".jpeg"} ALLOWED_HDR_EXT = {".jpg", ".jpeg", ".tif", ".tiff"} diff --git a/app/jobs.py b/src/script/app/jobs.py similarity index 100% rename from app/jobs.py rename to src/script/app/jobs.py diff --git a/app/routes.py b/src/script/app/routes.py similarity index 100% rename from app/routes.py rename to src/script/app/routes.py diff --git a/app/validation.py b/src/script/app/validation.py similarity index 100% rename from app/validation.py rename to src/script/app/validation.py diff --git a/templates/index.html b/src/templates/index.html similarity index 96% rename from templates/index.html rename to src/templates/index.html index 867c0d6..b91f174 100644 --- a/templates/index.html +++ b/src/templates/index.html @@ -4,7 +4,7 @@ Instagram HDR Assembler - +
@@ -61,11 +61,11 @@

Instagram HDR Assembler v{{ app_version }}

diff --git a/templates/result.html b/src/templates/result.html similarity index 94% rename from templates/result.html rename to src/templates/result.html index d860198..7fb8e5f 100644 --- a/templates/result.html +++ b/src/templates/result.html @@ -4,7 +4,7 @@ Instagram HDR Assembler — Result - +
@@ -46,11 +46,11 @@

Instagram HDR Assembler v{{ app_version }}