From d428cce70e18b471f80096d4ae3ab0218f76c404 Mon Sep 17 00:00:00 2001 From: David Kerkeslager Date: Fri, 13 May 2022 23:36:46 -0400 Subject: [PATCH] Add a config file --- .gitignore | 1 + app.py | 11 +++++++++-- config.json-example | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 config.json-example diff --git a/.gitignore b/.gitignore index 896cdee..38e88b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .env/ __pycache__/ +config.json diff --git a/app.py b/app.py index b87aa3a..3c899a8 100644 --- a/app.py +++ b/app.py @@ -1,6 +1,13 @@ +import json +import pathlib + import commonmark import flask +with open(pathlib.Path(__file__).parent / 'config.json') as f: + CONFIGURATION = json.loads(f.read()) + print(CONFIGURATION) + app = flask.Flask(__name__) @app.route('/') @@ -10,7 +17,7 @@ def index(): @app.route('/p/') def page(name): for ch in name: - if not ch in 'abcdefghijklmnopqrstuvwxyz_0123456789': + if not ch in 'abcdefghijklmnopqrstuvwxyz-0123456789': flask.abort(404) try: @@ -19,7 +26,7 @@ def page(name): except FileNotFoundError as e: flask.abort(404) - title = name.replace('_', ' ').title() + title = name.replace('-', ' ').title() return flask.render_template('page.html', content=content, title=title) diff --git a/config.json-example b/config.json-example new file mode 100644 index 0000000..9b7abdc --- /dev/null +++ b/config.json-example @@ -0,0 +1,3 @@ +{ + "directory": "/path/to/git/repo/base/directory" +} -- 2.20.1