diff --git a/README.md b/README.md index 9c52c5c..8c7bf82 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,15 @@ It progresses **only during your scheduled work hours** - During the day, the bar fills smoothly - End of Wednesday = **100% freedom** +### Configuration + +| Variable | Default | Description | +|--------|---------|-------------| +| WORK_START_TIME | 07:00 | Workday start (HH:MM) | +| WORK_END_TIME | 17:30 | Workday end (HH:MM) | +| WORK_DAYS | 0,1,2,3 | JS day numbers (Sun=0) | +| UPDATE_INTERVAL_MS | 60000 | Update frequency | + --- ## 🛠 Tech Stack diff --git a/app.py b/app.py index 7fcc529..b2b34d5 100644 --- a/app.py +++ b/app.py @@ -1,10 +1,41 @@ +import os from flask import Flask, render_template app = Flask(__name__) +def parse_time(value, default): + try: + hour, minute = map(int, value.split(":")) + return {"hour": hour, "minute": minute} + except Exception: + return default + @app.route("/") def index(): - return render_template("index.html") + start_time = parse_time( + os.getenv("WORK_START_TIME", "07:00"), + {"hour": 7, "minute": 0} + ) + end_time = parse_time( + os.getenv("WORK_END_TIME", "17:30"), + {"hour": 17, "minute": 30} + ) + + work_days = [ + int(d.strip()) + for d in os.getenv("WORK_DAYS", "0,1,2,3").split(",") + if d.strip().isdigit() + ] + + update_interval = int(os.getenv("UPDATE_INTERVAL_MS", "60000")) + + return render_template( + "index.html", + work_start=start_time, + work_end=end_time, + work_days=work_days, + update_interval=update_interval + ) if __name__ == "__main__": - app.run(host="0.0.0.0", port=5000, debug=True) + app.run(host="0.0.0.0", port=5000) diff --git a/templates/index.html b/templates/index.html index 072fef7..73c51fc 100644 --- a/templates/index.html +++ b/templates/index.html @@ -25,14 +25,34 @@
0%
- + + +