upload, save request order buig fixed
This commit is contained in:
34
server.py
34
server.py
@@ -22,12 +22,13 @@ import copy
|
||||
#stock_ticker = StockTicker()
|
||||
#print('API CALLER NOT STARTED')
|
||||
|
||||
open('log.txt', 'w').close() #wipe logs
|
||||
#open('log.txt', 'w').close() #wipe logs
|
||||
|
||||
|
||||
api_caller = pexpect.spawn("sudo -E taskset -c 3 python3 api_caller.py")
|
||||
api_caller.sendline('A')
|
||||
displaying_screensaver = False
|
||||
uploading = False
|
||||
screensaver_p = None
|
||||
professional = json.load(open('csv/display_settings.json', 'r'))[0] == "Professional"
|
||||
|
||||
@@ -35,7 +36,7 @@ command = 300
|
||||
tickerList = 0
|
||||
DelayTime = 20
|
||||
LastCommand = ''
|
||||
speedTime = 25
|
||||
speedTime = 25 #print('save')
|
||||
|
||||
LOGO_FOLDER = 'logos/'
|
||||
CSV_FOLDER = 'csv/new/'
|
||||
@@ -126,7 +127,7 @@ def index():
|
||||
|
||||
|
||||
def save_displaying(input_settings):
|
||||
|
||||
#print('save')
|
||||
|
||||
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']
|
||||
@@ -181,7 +182,7 @@ def stop():
|
||||
else:
|
||||
screensaver_p.close()
|
||||
|
||||
|
||||
|
||||
if displaying_screensaver:
|
||||
screensaver_p.close()
|
||||
ticker = pexpect.spawn("sudo -E python3 stockTicker.py")
|
||||
@@ -209,13 +210,19 @@ def display_format():
|
||||
|
||||
@app.route("/save", methods = ['PUT', 'POST', 'GET'])
|
||||
def save():
|
||||
print('save')
|
||||
global uploading
|
||||
while uploading:
|
||||
print('waiting for upload')
|
||||
|
||||
data = str(request.data.decode('utf-8'))
|
||||
|
||||
|
||||
input_settings = json.loads(data)
|
||||
|
||||
|
||||
|
||||
|
||||
print(input_settings)
|
||||
|
||||
save_displaying(input_settings['displaying'])
|
||||
|
||||
input_settings= input_settings['feature_settings']
|
||||
@@ -231,6 +238,17 @@ def save():
|
||||
save_sports_settings(input_settings)
|
||||
|
||||
elif feature in ['Custom GIFs', 'Custom Images']:
|
||||
|
||||
|
||||
images = request.files
|
||||
names = list(request.files.keys())
|
||||
print(names)
|
||||
|
||||
for name in names:
|
||||
print(name)
|
||||
images[name].save('user_uploads/' +name)
|
||||
|
||||
|
||||
save_image_settings(input_settings)
|
||||
|
||||
elif feature == 'Custom Messages':
|
||||
@@ -241,6 +259,9 @@ def save():
|
||||
# saves files uploaded to the webpage for images and GIFs
|
||||
@app.route("/upload", methods = ['PUT', 'POST', 'GET'])
|
||||
def upload():
|
||||
print('upload')
|
||||
global uploading
|
||||
uploading = True
|
||||
try:
|
||||
|
||||
images = request.files
|
||||
@@ -251,6 +272,7 @@ def upload():
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
uploading = False
|
||||
return index()
|
||||
|
||||
def remove_old_uploads():
|
||||
|
Reference in New Issue
Block a user