code tidied up, redundant api calls removed and real time brightness and speed controls added
This commit is contained in:
17
server.py
17
server.py
@@ -30,7 +30,7 @@ ALLOWED_EXTENSIONS = {'csv', 'png'}
|
||||
#ticker.stdin.write(b'from server')
|
||||
#print(ticker.stdout.readlines())
|
||||
#(output, errs)
|
||||
child = pexpect.spawn("sudo -E python3 stockTicker.py")
|
||||
ticker = pexpect.spawn("sudo -E python3 stockTicker.py")
|
||||
|
||||
#stock_ticker = StockTicker()
|
||||
|
||||
@@ -89,9 +89,20 @@ def Speed():
|
||||
global speedTime
|
||||
speedTime = request.form['text']
|
||||
print(speedTime)
|
||||
ticker.sendline(speedTime)
|
||||
global LastCommand
|
||||
LastCommand = 'Change Speed'
|
||||
return hello()
|
||||
|
||||
@app.route("/Brightness", methods=['POST'])
|
||||
def Brightness():
|
||||
global brightness
|
||||
brightness = request.form['text']
|
||||
print(brightness)
|
||||
ticker.sendline(brightness)
|
||||
global LastCommand
|
||||
LastCommand = 'Change Brightness'
|
||||
return hello()
|
||||
|
||||
@app.route("/Ticker", methods=['POST'])
|
||||
def Ticker():
|
||||
@@ -143,7 +154,7 @@ def matrix():
|
||||
#child.sendline('sent from server')
|
||||
|
||||
#process = Popen(["sudo", "-E", "python3", "stockTicker.py"], stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
||||
child.sendline('S')
|
||||
ticker.sendline('S')
|
||||
|
||||
print('back in flask')
|
||||
|
||||
@@ -155,7 +166,7 @@ def matrix():
|
||||
try:
|
||||
#stock_ticker.stopStockTicker()
|
||||
LastCommand = 'Stop display at next checkpoint'
|
||||
child.sendline('K')
|
||||
ticker.sendline('K')
|
||||
except:
|
||||
print("none running")
|
||||
elif "Shutdown the pi" in request.form:
|
||||
|
Reference in New Issue
Block a user