From 89901f2663c10b2b42bde10665b566c08b678532 Mon Sep 17 00:00:00 2001 From: schneefux Date: Sat, 28 May 2016 18:05:31 +0200 Subject: insert rendered html into db --- app.py | 7 ++++--- templates/index.html | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index cf0b0d4..1b878b5 100644 --- a/app.py +++ b/app.py @@ -75,14 +75,15 @@ def close_db(exception): @app.route('/') def root(): jokes = db().getJokes() - for joke in jokes: - joke['text'] = Markup(markdown.markdown(joke['text'], extensions=['markdown.extensions.nl2br'], output_format="html5", safe_mode="remove")) # TODO cache TODO safe_mode deprecated + #for joke in jokes: return render_template('index.html', jokes=jokes) @app.route('/submit', methods=['POST']) def submit(): text = request.form['text'] - db().addJoke(text) # TODO auth + #joke['text'] = + text = Markup(markdown.markdown(text, extensions=['markdown.extensions.nl2br'], output_format="html5", safe_mode="remove")) # TODO safe_mode deprecated + db().addJoke(text) return redirect('/') @app.route('/vote', methods=['POST']) diff --git a/templates/index.html b/templates/index.html index ef7559d..ca8f25b 100644 --- a/templates/index.html +++ b/templates/index.html @@ -20,7 +20,7 @@
-

{{ joke.text }}

+

{{ joke.text|safe }}

-- cgit v1.3.1