summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmma Terzioglu <emreterzioglu49@gmail.com>2026-03-14 21:16:35 -0700
committerEmma Terzioglu <emreterzioglu49@gmail.com>2026-03-14 21:16:35 -0700
commit4a998d03ebca44414d093dfba789986c0307f9fd (patch)
tree1ad3da5bf35bb0d10f3a6b3ffb3af660ec6a2576
parent9e094bebec1e2a7a319bdcac05f745292197a59a (diff)
add switch to disable admin control panel
-rw-r--r--.env.template1
-rw-r--r--src/__init__.py5
-rw-r--r--src/templates/base.html2
3 files changed, 6 insertions, 2 deletions
diff --git a/.env.template b/.env.template
index 24cfd32..bef02e6 100644
--- a/.env.template
+++ b/.env.template
@@ -1,4 +1,5 @@
STAGE=
DATABASE=
+ADMIN_ENABLED=
ADMIN_PASSWORD=
SECRET_KEY=
diff --git a/src/__init__.py b/src/__init__.py
index f6ad74a..9e66fc8 100644
--- a/src/__init__.py
+++ b/src/__init__.py
@@ -6,12 +6,15 @@ from . import admin, blog, website
app = q.Quart(__name__)
app.config.from_mapping(dotenv_values())
+app.config["admin_enabled"] = app.config.get("ADMIN_ENABLED") == "true"
+
app.debug = app.config["STAGE"] == "debug"
app.permanent_session_lifetime = admin.MAX_LOGIN_TIME
app.register_blueprint(blog.blueprint)
app.register_blueprint(website.blueprint)
-app.register_blueprint(admin.blueprint)
+if app.config["admin_enabled"]:
+ app.register_blueprint(admin.blueprint)
@app.while_serving
diff --git a/src/templates/base.html b/src/templates/base.html
index 935ab5e..ff1f3c6 100644
--- a/src/templates/base.html
+++ b/src/templates/base.html
@@ -2,7 +2,7 @@
<a class="label" {{ "active" if label_active(path) else "" }} href="{{ path }}">{{ name or path }}</a>
{%- endmacro %}
-{% set adminmode = request.path.startswith("/admin") %}
+{% set adminmode = request.path.startswith("/admin") and config["admin_enabled"] and request.path != "/admin/login" %}
<!DOCTYPE html>
<html>