save screensaver settings

This commit is contained in:
Justin 2023-08-22 22:24:16 +08:00 committed by GitHub
parent 58e74f44d9
commit ca878608d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1701,6 +1701,45 @@ def saveSchedulerSettings():
return index() return index()
@app.route("/saveScreensaverSettings", methods = ['PUT', 'POST'])
def saveScreensaverSettings():
data = request.data.decode('utf-8')
input_settings = json.loads(data)
try:
with open('clock_screensaver.json','r') as f:
clock_screensaver = json.load(f)
except:
clock_screensaver = {"clock1": {"time_color": "White", "weekday_color": "Cyan", "date_color": "Blue", "timezone": "Etc/GMT+4", "display_seconds": True, "display_pm": True, "12hour": True}, "clock2": {"time_color": "Orange", "date_color": "White", "timezone": "Etc/GMT+4", "display_seconds": True, "display_pm": True, "12hour": True}, "world_clock": {"city_color": "White", "display_seconds": True, "display_pm": True, "12hour": True}}
clock_screensaver['clock1']['time_color'] = input_settings['clock1_timecolor']
clock_screensaver['clock1']['weekday_color'] = input_settings['clock1_weekdaycolor']
clock_screensaver['clock1']['date_color'] = input_settings['clock1_datecolor']
clock_screensaver['clock1']['timezone'] = input_settings['clock1_timezone']
clock_screensaver['clock1']['display_seconds'] = input_settings['clock1_displayseconds']
clock_screensaver['clock1']['display_pm'] = input_settings['clock1_displaypm']
clock_screensaver['clock1']['12hour'] = input_settings['clock1_12hour']
clock_screensaver['clock2']['time_color'] = input_settings['clock2_timecolor']
clock_screensaver['clock2']['date_color'] = input_settings['clock2_datecolor']
clock_screensaver['clock2']['timezone'] = input_settings['clock2_timezone']
clock_screensaver['clock2']['display_pm'] = input_settings['clock2_displaypm']
clock_screensaver['clock2']['12hour'] = input_settings['clock2_12hour']
clock_screensaver['world_clock']['city_color'] = input_settings['worldclock_citycolor']
clock_screensaver['world_clock']['display_pm'] = input_settings['worldclock_displaypm']
clock_screensaver['world_clock']['12hour'] = input_settings['worldclock_12hour']
clock_screensaver['world_clock']['display_seconds'] = input_settings['worldclock_displayseconds']
with open('clock_screensaver.json', 'w') as f:
json.dump(clock_screensaver,f)
return index()
@app.route("/setTop20or10", methods = ['PUT', 'POST']) @app.route("/setTop20or10", methods = ['PUT', 'POST'])
def setTop20or10(): def setTop20or10():