diff --git a/main.py b/main.py index 8347077..9c15acd 100644 --- a/main.py +++ b/main.py @@ -1,30 +1,33 @@ from flask import Flask, render_template, redirect import datetime +from textwrap import wrap app = Flask(__name__); -last_value: str +values = "" try: with open("bozo", 'r') as f: - last_value: str = f.read() + values = f.read() except: + values = str(datetime.date.today()) with open("bozo", 'w+') as f: - last_value = str(datetime.date.today()) - f.write(last_value) + f.write(values) @app.route("/api/update", methods = ['POST']) def update(): - last_value = str(datetime.date.today()) - print(last_value) - with open("bozo", 'w+') as f: - f.write(last_value) - return render_template('home.html', date = last_value) + global values + new_value = str(datetime.date.today()) + if new_value not in values: + values += " " + new_value + with open("bozo", 'w+') as f: + f.write(values) + return redirect('/') @app.route("/", methods = ['GET']) def normal(): - print(last_value) - return render_template('home.html', date = last_value) + print(values.split(" ")) + return render_template('home.html', dates = wrap(values, 10)) if __name__ == '__main__': app.run(host='0.0.0.0', port=5000, debug=1) diff --git a/templates/home.html b/templates/home.html index 6a36bb5..0d4b8ce 100644 --- a/templates/home.html +++ b/templates/home.html @@ -6,7 +6,9 @@

Ca42

-

{{date}}

+ {% for date in dates %} +

{{date}}

+ {% endfor %}