add actions when pancacke is ready

This commit is contained in:
FKD13 2023-12-06 13:39:39 +01:00
parent 8a4e366516
commit baa3a02a15
No known key found for this signature in database
3 changed files with 19 additions and 9 deletions

View file

@ -1 +1 @@
python 3.10.4
python 3.11.6

25
main.py
View file

@ -2,8 +2,9 @@ import pickle
from datetime import datetime
import humanize
from flask import Flask, render_template, request, redirect, url_for
from flask import Flask, render_template, request, redirect
from os.path import exists
from requests import post, exceptions
app = Flask(__name__)
@ -62,6 +63,19 @@ def save_people():
people_file.close()
def update_index(index):
people[index].status += 1
if people[index].status == 2:
try:
post('http://10.1.0.224:8080/blink')
post('http://10.1.2.3', data=f"ScrollingText >>> {people[index].name} <<< Enjoy! ")
post('http://10.1.2.3', data="Option text_trailingWhitespace 1")
except exceptions.ConnectionError:
print('Failed to blink the light')
elif people[index].status == 3:
people.remove(people[index])
@app.route("/")
def home():
return render_template("home.html", people=people)
@ -73,15 +87,10 @@ def status_update():
result = request.form
if "index" in result:
index = int(request.form["index"])
people[index].status += 1
if people[index].status == 3:
people.remove(people[index])
update_index(index)
if "name" in result:
index = people.index(Person(request.form["name"]))
print(index)
people[index].status += 1
if people[index].status == 3:
people.remove(people[index])
update_index(index)
save_people()
return redirect("/")

View file

@ -1,2 +1,3 @@
flask
humanize
requests