def user_config(): # Current user config, from disk. current_config = json.loads(get_user_conf_raw()) if request.method == "POST": # Updated config, from client. config = request.form.get("config") try: # Only save if parseable JSON. config = json.loads(config) # Do not allow some settings to be modified or removed # while running with --cloud, by overwriting whatever # value was set (or unset) using the current # configuration. if StaticConfig.CLOUD: for setting in StaticConfig.CLOUD_UNMODIFIABLE_CONFIG_VALUES: if setting in current_config: config[setting] = current_config[setting] else: config.pop(setting, None) # Save the updated configuration. save_user_conf_raw(json.dumps(config)) current_config = config except json.JSONDecodeError as e: app.logger.debug(e) return current_config
def user_config(): if request.method == "POST": config = request.form.get("config") try: # only save if parseable JSON json.loads(config) save_user_conf_raw(config) except json.JSONDecodeError as e: app.logger.debug(e) return "" else: return get_user_conf_raw()