persistant settings added
This commit is contained in:
33
server.py
33
server.py
@@ -46,13 +46,15 @@ def process_file(path, filename):
|
||||
for row in new_csv:
|
||||
default_csv.writerow(row)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
@app.route("/", methods=['GET', 'POST'])
|
||||
def hello():
|
||||
global command
|
||||
|
||||
|
||||
now = datetime.datetime.now()
|
||||
timeString = now.strftime("%Y-%m-%d %H:%M")
|
||||
LogoList = os.listdir('logos')
|
||||
@@ -88,10 +90,20 @@ def Delay():
|
||||
|
||||
@app.route("/Speed", methods=['POST'])
|
||||
def Speed():
|
||||
global speedTime
|
||||
speedTime = request.form['text']
|
||||
print(speedTime)
|
||||
ticker.sendline(speedTime)
|
||||
global speed
|
||||
speed = request.form['text']
|
||||
print(speed)
|
||||
ticker.sendline(speed)
|
||||
|
||||
f = open('csv/settings.csv', 'r')
|
||||
CSV = csv.reader(f)
|
||||
for line in CSV:
|
||||
_, brightness = line
|
||||
f.close()
|
||||
|
||||
f = open('csv/settings.csv', 'w+')
|
||||
f.write(str(speed) + ',' + brightness)
|
||||
f.close()
|
||||
global LastCommand
|
||||
LastCommand = 'Change Speed'
|
||||
return hello()
|
||||
@@ -102,6 +114,17 @@ def Brightness():
|
||||
brightness = int(request.form['text'])-1
|
||||
print(brightness)
|
||||
ticker.sendline(str(brightness))
|
||||
|
||||
f = open('csv/settings.csv', 'r')
|
||||
CSV = csv.reader(f)
|
||||
for line in CSV:
|
||||
speed, _ = line
|
||||
f.close()
|
||||
|
||||
f = open('csv/settings.csv', 'w+')
|
||||
f.write(str(speed) + ',' + str(brightness))
|
||||
f.close()
|
||||
|
||||
global LastCommand
|
||||
LastCommand = 'Change Brightness'
|
||||
return hello()
|
||||
|
Reference in New Issue
Block a user