get custom msg value func backend

This commit is contained in:
Justin 2023-07-07 16:23:50 +08:00 committed by GitHub
parent 843b5fcc81
commit 6b7913aa97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1515,6 +1515,24 @@ def setTop20or10():
return index()
@app.route("/fetchCustomMsg", methods=["POST"])
def fetch_custom_msg():
value = request.data.decode('utf-8')
value2 = json.loads(value)
try:
with open("csv/message_settings.json") as f:
data = json.load(f)
except:
data = {"feature": "Custom Messages", "speed": "medium", "speed2": "medium", "animation": "down", "title": False, "messages": [{"name": "welcome", "text": "Welcome to Fintic!", "text_colour": "White", "size": "Large", "background_colour": "Black"}, {"name": "get_started", "text": "To get started, connect your device to the \"Fintic Hotspot\" and access \"fintic.local:1024\" on your web browser. You can connect your ticker to Wi-Fi there.", "text_colour": "White", "size": "Small", "background_colour": "Black"}]}
for i, each in enumerate(data['messages']):
if each['name'] == value2:
the_info = data['messages'][i]
break
else:
the_info = {}
return (the_info)
if __name__ == "__main__":
app.run(host='0.0.0.0', port=1024, debug=False) # the debuggger causes flickering