diff --git a/README.md b/README.md index 040f4cc..d76bff5 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,13 @@ personal diary with txt style, can be private! ## environment variables -| name | description | required | -| :----------------: | :-------------------: | :-------------: | -| `TD_USERNAME` | user name | no | -| `TD_USERPASS` | user password | yes | -| `TD_PRIVATE` | post visibility | empty = `false` | -| `TD_LOGINLIFETIME` | login lifetime (days) | empty = `7` | +| name | description | required | +| :----------------: | :---------------------------------: | :-------------: | +| `TD_USERNAME` | user name | no | +| `TD_USERPASS` | user password | yes | +| `TD_PRIVATE` | post visibility | empty = `false` | +| `TD_LOGINLIFETIME` | login lifetime (days) | empty = `7` | +| `TD_BASEROUTE` | base route, must start with a slash | no | ## volumes (docker) diff --git a/src/app.py b/src/app.py index 79115d3..28e35d7 100644 --- a/src/app.py +++ b/src/app.py @@ -11,7 +11,7 @@ app = Flask(__name__, static_url_path="/") for file in glob("*/routes/*.py"): module = file.replace("/", ".").split(".")[-2] exec(f"from routes.{module} import router as {module}") - exec(f"app.register_blueprint({module})") + exec(f"app.register_blueprint({module}, url_prefix='{Config.base}')") app.secret_key = urandom(12) diff --git a/src/routes/index.py b/src/routes/index.py index 189dc6a..ea39417 100644 --- a/src/routes/index.py +++ b/src/routes/index.py @@ -38,11 +38,11 @@ def new_post(post_id: int | None) -> Response: update = create_post(filename, content) flash( - f"post {'updated' if update else 'created'}." + f"post {'updated' if update else 'created'}." ) else: flash(f"invalid post: {content}") else: flash("you can't do that.") - return redirect("/") + return redirect(Config.base) diff --git a/src/routes/login.py b/src/routes/login.py index 76d6a02..3d2c0cd 100644 --- a/src/routes/login.py +++ b/src/routes/login.py @@ -30,4 +30,4 @@ def check() -> Response: else: flash("already logged.") - return redirect("/") + return redirect(Config.base) diff --git a/src/routes/read.py b/src/routes/read.py index 4d67c89..a719efd 100644 --- a/src/routes/read.py +++ b/src/routes/read.py @@ -37,4 +37,4 @@ def remove_post(file: int) -> Response: else: flash(f"{filename} doesn't exists") - return redirect("/") + return redirect(Config.base) diff --git a/src/templates/header.html b/src/templates/header.html index b417d24..ef0319c 100644 --- a/src/templates/header.html +++ b/src/templates/header.html @@ -2,7 +2,7 @@