From: David Kerkeslager Date: Sat, 14 May 2022 03:22:28 +0000 (-0400) Subject: Change main.py to app.py to run simply with "flask run". Add a demo of internal linking X-Git-Url: https://code.kerkeslager.com/?p=wiki;a=commitdiff_plain;h=7e636a35b269d9bd445eef58640b2bd1b8e6b16e Change main.py to app.py to run simply with "flask run". Add a demo of internal linking --- diff --git a/app.py b/app.py new file mode 100644 index 0000000..b87aa3a --- /dev/null +++ b/app.py @@ -0,0 +1,26 @@ +import commonmark +import flask + +app = flask.Flask(__name__) + +@app.route('/') +def index(): + return 'Hello, world' + +@app.route('/p/') +def page(name): + for ch in name: + if not ch in 'abcdefghijklmnopqrstuvwxyz_0123456789': + flask.abort(404) + + try: + with open('pages/{}.md'.format(name), 'r') as f: + content = commonmark.commonmark(f.read()) + except FileNotFoundError as e: + flask.abort(404) + + title = name.replace('_', ' ').title() + + return flask.render_template('page.html', content=content, title=title) + + diff --git a/main.py b/main.py deleted file mode 100644 index b87aa3a..0000000 --- a/main.py +++ /dev/null @@ -1,26 +0,0 @@ -import commonmark -import flask - -app = flask.Flask(__name__) - -@app.route('/') -def index(): - return 'Hello, world' - -@app.route('/p/') -def page(name): - for ch in name: - if not ch in 'abcdefghijklmnopqrstuvwxyz_0123456789': - flask.abort(404) - - try: - with open('pages/{}.md'.format(name), 'r') as f: - content = commonmark.commonmark(f.read()) - except FileNotFoundError as e: - flask.abort(404) - - title = name.replace('_', ' ').title() - - return flask.render_template('page.html', content=content, title=title) - - diff --git a/pages/demo.md b/pages/demo.md index 3740b66..5f676dc 100644 --- a/pages/demo.md +++ b/pages/demo.md @@ -12,7 +12,7 @@ ##### Heading 5 -[Link](https://www.google.com) +[Link](demo2) ![Image](http://url/a.png)