user choosing options to display working on new frontend
This commit is contained in:
43
server.py
43
server.py
@@ -17,6 +17,7 @@ import time
|
||||
import json
|
||||
from multiprocessing import Process
|
||||
from subprocess import Popen, PIPE
|
||||
import numpy as np
|
||||
#stock_ticker = StockTicker()
|
||||
api_caller = pexpect.spawn("sudo -E python3 api_caller.py")
|
||||
|
||||
@@ -267,8 +268,48 @@ def AddLogo():
|
||||
return hello()
|
||||
return hello()
|
||||
|
||||
@app.route("/matrix", methods=['POST'])
|
||||
|
||||
@app.route("/start", methods = ['PUT', 'POST'])
|
||||
def start():
|
||||
data = str(request.data)
|
||||
|
||||
|
||||
|
||||
all_settings = ['Stocks', 'Crypto', 'Forex', 'Current Weather', 'Daily Forecast', 'News', 'Sports (Upcoming Games)', 'Sports (Past Games)',
|
||||
'Sports (Live Games)', 'Sports (Team Stats)', 'Custom Images', 'Custom GIFs', 'Custom Messages']
|
||||
positions = []
|
||||
display_settings = []
|
||||
|
||||
for setting in all_settings:
|
||||
pos = data.find(setting)
|
||||
if pos != -1:
|
||||
display_settings.append(setting)
|
||||
positions.append(pos)
|
||||
|
||||
# sort settings by display
|
||||
inds = np.argsort(positions)
|
||||
display_settings = np.array(display_settings)[inds]
|
||||
|
||||
with open('csv/display_settings.json', 'w+') as f:
|
||||
json.dump(list(display_settings), f)
|
||||
|
||||
ticker.sendline('K')
|
||||
ticker.sendline('A')
|
||||
return hello()
|
||||
|
||||
@app.route("/stop")
|
||||
def stop():
|
||||
ticker.sendline('K')
|
||||
return hello()
|
||||
|
||||
@app.route("/shutdown")
|
||||
def shutdown():
|
||||
os.system("sudo shutdown now")
|
||||
return hello()
|
||||
|
||||
@app.route("/matrix")
|
||||
def matrix():
|
||||
|
||||
if "Run Stocks" in request.form:
|
||||
ticker.sendline('K')
|
||||
ticker.sendline('S')
|
||||
|
Reference in New Issue
Block a user