ca42/main.py

34 lines
809 B
Python
Raw Normal View History

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