ca42/main.py
2024-09-13 01:56:28 +02:00

34 lines
871 B
Python

from flask import Flask, render_template, redirect
import datetime
from textwrap import wrap
app = Flask(__name__);
values = ""
try:
with open("bozo", 'r') as f:
values = f.read()
except:
values = str(datetime.date.today())
with open("bozo", 'w+') as f:
f.write(values)
@app.route("/api/update", methods = ['POST'])
def update():
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(values.split(" "))
return render_template('home.html', dates = wrap(values, 10), total = len(values.split(' ')), days = values.split(' ')[-1])
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=1)