new frontend basic functionality working
This commit is contained in:
60
server.py
60
server.py
@@ -51,7 +51,7 @@ def process_file(path, filename):
|
||||
|
||||
app = Flask(__name__)
|
||||
@app.route("/", methods=['GET', 'POST'])
|
||||
def hello():
|
||||
def index():
|
||||
global command
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ def Runtime():
|
||||
|
||||
|
||||
LastCommand = 'Change runtime'
|
||||
return hello()
|
||||
return index()
|
||||
|
||||
@app.route("/Delay", methods=['POST'])
|
||||
def Delay():
|
||||
@@ -87,7 +87,7 @@ def Delay():
|
||||
|
||||
global LastCommand
|
||||
LastCommand = 'Change Delay'
|
||||
return hello()
|
||||
return index()
|
||||
|
||||
@app.route("/Speed", methods=['POST'])
|
||||
def Speed():
|
||||
@@ -109,7 +109,7 @@ def Speed():
|
||||
f.close()
|
||||
global LastCommand
|
||||
LastCommand = 'Change Speed'
|
||||
return hello()
|
||||
return index()
|
||||
|
||||
@app.route("/Brightness", methods=['POST'])
|
||||
def Brightness():
|
||||
@@ -132,7 +132,7 @@ def Brightness():
|
||||
|
||||
global LastCommand
|
||||
LastCommand = 'Change Brightness'
|
||||
return hello()
|
||||
return index()
|
||||
|
||||
@app.route("/DisplayText", methods=['POST'])
|
||||
def DisplayText():
|
||||
@@ -142,7 +142,7 @@ def DisplayText():
|
||||
f.close()
|
||||
ticker.sendline('K')
|
||||
ticker.sendline('T')
|
||||
return hello()
|
||||
return index()
|
||||
|
||||
@app.route("/SetNews", methods=['POST'])
|
||||
def SetNews():
|
||||
@@ -171,7 +171,7 @@ def SetNews():
|
||||
|
||||
api_caller.sendline('R')
|
||||
|
||||
return hello()
|
||||
return index()
|
||||
|
||||
@app.route("/SetWeather", methods=['POST'])
|
||||
def SetWeather():
|
||||
@@ -184,7 +184,7 @@ def SetWeather():
|
||||
f.close()
|
||||
api_caller.sendline('R')
|
||||
|
||||
return hello()
|
||||
return index()
|
||||
|
||||
@app.route("/DisplayGIF", methods=['POST'])
|
||||
def DisplayGIF():
|
||||
@@ -206,7 +206,7 @@ def DisplayGIF():
|
||||
ticker.sendline('K')
|
||||
ticker.sendline('G')
|
||||
return hello()
|
||||
return hello()
|
||||
return index()
|
||||
|
||||
@app.route("/DisplayImage", methods=['POST'])
|
||||
def DisplayImage():
|
||||
@@ -228,7 +228,7 @@ def DisplayImage():
|
||||
ticker.sendline('K')
|
||||
ticker.sendline('I')
|
||||
return hello()
|
||||
return hello()
|
||||
return index()
|
||||
|
||||
|
||||
@app.route("/Ticker", methods=['POST'])
|
||||
@@ -248,7 +248,7 @@ def Ticker():
|
||||
global LastCommand
|
||||
LastCommand = 'Change CSV file'
|
||||
return hello()
|
||||
return hello()
|
||||
return index()
|
||||
|
||||
@app.route("/AddLogo", methods=['POST'])
|
||||
def AddLogo():
|
||||
@@ -266,23 +266,31 @@ def AddLogo():
|
||||
global LastCommand
|
||||
LastCommand = 'Add a new logo file'
|
||||
return hello()
|
||||
return hello()
|
||||
return index()
|
||||
|
||||
professional = False
|
||||
|
||||
|
||||
@app.route("/start", methods = ['PUT', 'POST'])
|
||||
def start():
|
||||
print(professional)
|
||||
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']
|
||||
|
||||
if professional:
|
||||
all_settings = ['Stocks', 'Crypto', 'Forex', 'Current Weather', 'News']
|
||||
|
||||
|
||||
positions = []
|
||||
display_settings = []
|
||||
|
||||
for setting in all_settings:
|
||||
pos = data.find(setting)
|
||||
if pos != -1:
|
||||
if professional:
|
||||
setting += ' Prof'
|
||||
display_settings.append(setting)
|
||||
positions.append(pos)
|
||||
|
||||
@@ -294,18 +302,32 @@ def start():
|
||||
json.dump(list(display_settings), f)
|
||||
|
||||
ticker.sendline('K')
|
||||
ticker.sendline('A')
|
||||
return hello()
|
||||
|
||||
ticker.sendline('A')
|
||||
return index()
|
||||
|
||||
@app.route("/display_format", methods = ['PUT', 'POST', 'GET'])
|
||||
def display_format():
|
||||
global professional
|
||||
data = str(request.data)
|
||||
if "Standard" in data:
|
||||
professional = False
|
||||
elif "Professional" in data:
|
||||
professional = True
|
||||
|
||||
print(professional)
|
||||
return index()
|
||||
|
||||
@app.route("/stop")
|
||||
def stop():
|
||||
print('stop')
|
||||
ticker.sendline('K')
|
||||
return hello()
|
||||
return index()
|
||||
|
||||
@app.route("/shutdown")
|
||||
def shutdown():
|
||||
os.system("sudo shutdown now")
|
||||
return hello()
|
||||
return index()
|
||||
|
||||
@app.route("/matrix")
|
||||
def matrix():
|
||||
@@ -381,7 +403,7 @@ def matrix():
|
||||
os.system("sudo shutdown now")
|
||||
except:
|
||||
print("couldn't shutdown")
|
||||
return hello()
|
||||
return index()
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
|
Reference in New Issue
Block a user