From 9406e1fc50326ede8e43894db5075878b6ddafa5 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 2 Jun 2023 10:11:06 +0200 Subject: [PATCH] Added html template --- game.py | 15 ++++++--------- templates/index.html | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 templates/index.html diff --git a/game.py b/game.py index fee10a1..6278a8e 100755 --- a/game.py +++ b/game.py @@ -1,7 +1,7 @@ #! /bin/python3 from random import choice -from flask import Flask +from flask import Flask, render_template app = Flask(__name__, static_url_path='', static_folder='static', @@ -12,19 +12,16 @@ def hello(): title = 'A oder B' separator = ' oder ' - header = ''+str(title)+'
' - footer = "
" - - ablines = "" + ablines = [] lines = getContent() for line in lines: ab = line.split(separator) - ablines = '
'+str(ab[0])+'
'+str(separator)+'
'+str(ab[1])+'
'+ablines + ablines.append( + {'A': str(ab[0]), 'B': str(ab[1])} + ) - output = header+ablines+footer - - return output + return render_template('index.html', title=title, separator=separator, content=ablines) def getContent(): lines = [a.strip() for a in open("ab.txt").readlines()] diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..964c9f6 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,18 @@ + + + {{ title }} + + + +
+ + {% for question in content %} +
+
{{ question['A'] }}
+
{{ separator }}
+
{{ question['B'] }}
+
+ {% endfor %} +
+ +