diff options
| author | Emma Terzioglu <emreterzioglu49@gmail.com> | 2026-03-14 21:16:35 -0700 |
|---|---|---|
| committer | Emma Terzioglu <emreterzioglu49@gmail.com> | 2026-03-14 21:16:35 -0700 |
| commit | 4a998d03ebca44414d093dfba789986c0307f9fd (patch) | |
| tree | 1ad3da5bf35bb0d10f3a6b3ffb3af660ec6a2576 /src | |
| parent | 9e094bebec1e2a7a319bdcac05f745292197a59a (diff) | |
add switch to disable admin control panel
Diffstat (limited to 'src')
| -rw-r--r-- | src/__init__.py | 5 | ||||
| -rw-r--r-- | src/templates/base.html | 2 |
2 files changed, 5 insertions, 2 deletions
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> |
