From b62e73e3fbdc79f2f40ce564d6fbeaef3234cd6e Mon Sep 17 00:00:00 2001 From: RGalyaviev Date: Wed, 3 Sep 2025 15:59:36 +0300 Subject: [PATCH] Add missing /admin/edit/ route (fix BuildError) --- app.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/app.py b/app.py index 95fe9b7..bf8e73e 100644 --- a/app.py +++ b/app.py @@ -148,6 +148,32 @@ def create_app(): base_url = request.host_url.rstrip("/") return render_template("admin.html", pages=pages, base_url=base_url) + @app.route("/admin/edit/", methods=["GET", "POST"]) + def admin_edit(pid: int): + login_required() + db = get_db() + if request.method == "POST": + title = request.form.get("title", "").strip() + html = request.form.get("html", "").strip() + if not html: + flash("HTML не может быть пустым.", "error") + else: + db.execute( + "UPDATE pages SET title = ?, html = ? WHERE id = ?", + (title, html, pid), + ) + db.commit() + flash("Страница обновлена.", "success") + return redirect(url_for("admin")) + + row = db.execute( + "SELECT id, uuid, title, html, created_at FROM pages WHERE id = ?", + (pid,), + ).fetchone() + if row is None: + abort(404) + return render_template("edit.html", page=row) + @app.route("/admin/delete/", methods=["POST"]) def admin_delete(pid: int): login_required()