feat: added PWA support
This commit is contained in:
12
app.py
12
app.py
@@ -30,7 +30,7 @@ APP_PASSWORD = os.environ.get("PASSWORD", "")
|
||||
def require_login():
|
||||
if not APP_PASSWORD:
|
||||
return
|
||||
if request.endpoint in ("login", "static"):
|
||||
if request.endpoint in ("login", "static", "service_worker", "offline"):
|
||||
return
|
||||
if not session.get("authenticated"):
|
||||
if request.path.startswith("/api/"):
|
||||
@@ -170,6 +170,16 @@ def run_download(job_id: str, urls: list[str], options: dict):
|
||||
jobs[job_id]["output"] = jobs[job_id].get("output", []) + [str(e)]
|
||||
|
||||
|
||||
@app.route("/sw.js")
|
||||
def service_worker():
|
||||
return send_from_directory("static", "sw.js", mimetype="application/javascript")
|
||||
|
||||
|
||||
@app.route("/offline")
|
||||
def offline():
|
||||
return send_from_directory("static", "offline.html")
|
||||
|
||||
|
||||
@app.route("/login", methods=["GET", "POST"])
|
||||
def login():
|
||||
if request.method == "POST":
|
||||
|
||||
Reference in New Issue
Block a user