Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -181,7 +181,6 @@ def index():
|
|
181 |
|
182 |
# Пример данных настроек
|
183 |
settings = {
|
184 |
-
'api_key_sys': 'default_api_key_sys',
|
185 |
'vk_api_key': 'vk_api_key_setting',
|
186 |
'crypto_key_sys': 'crypto_key_sys_setting',
|
187 |
'senler_token': 'senler_token_setting',
|
@@ -192,10 +191,9 @@ settings = {
|
|
192 |
}
|
193 |
|
194 |
def save_settings(settings_dict):
|
195 |
-
global
|
196 |
|
197 |
# Присваиваем значения из словаря соответствующим переменным
|
198 |
-
api_key_sys_ser = settings_dict.get('api_key_sys', '')
|
199 |
vk_api_key_ser = settings_dict.get('vk_api_key', '')
|
200 |
crypto_key_sys_ser = settings_dict.get('crypto_key_sys', '')
|
201 |
senler_token_ser = settings_dict.get('senler_token', '')
|
@@ -205,7 +203,6 @@ def save_settings(settings_dict):
|
|
205 |
call_api_key = settings_dict.get('call_api_key', '')
|
206 |
|
207 |
print(f"Сохраненные настройки:")
|
208 |
-
print(f"api_key_sys: {api_key_sys_ser}")
|
209 |
print(f"vk_api_key: {vk_api_key_ser}")
|
210 |
print(f"crypto_key_sys: {crypto_key_sys_ser}")
|
211 |
print(f"senler_token: {senler_token_ser}")
|
@@ -216,31 +213,31 @@ def save_settings(settings_dict):
|
|
216 |
|
217 |
@app.route('/load_settings', methods=['POST'])
|
218 |
def get_settings():
|
219 |
-
#
|
220 |
-
|
221 |
-
|
|
|
|
|
222 |
return jsonify({"error": "Unauthorized access"}), 403
|
223 |
|
224 |
return jsonify(settings)
|
225 |
|
226 |
@app.route('/save_settings', methods=['POST'])
|
227 |
def save_settings_route():
|
228 |
-
#
|
229 |
-
|
230 |
-
|
|
|
|
|
231 |
return jsonify({"error": "Unauthorized access"}), 403
|
232 |
|
233 |
data = request.json.get('data', {})
|
234 |
if data:
|
235 |
-
|
236 |
-
if value is not None:
|
237 |
-
settings[key] = value
|
238 |
-
save_settings(settings)
|
239 |
return jsonify({'status': 'success'})
|
240 |
else:
|
241 |
return jsonify({'status': 'error', 'message': 'No data provided'}), 400
|
242 |
|
243 |
-
|
244 |
@app.route('/set')
|
245 |
def index_set():
|
246 |
return render_template('settings.html')
|
@@ -254,6 +251,8 @@ def index_set():
|
|
254 |
|
255 |
|
256 |
|
|
|
|
|
257 |
mapping_template = {
|
258 |
"username": "name",
|
259 |
"phone": "phone",
|
|
|
181 |
|
182 |
# Пример данных настроек
|
183 |
settings = {
|
|
|
184 |
'vk_api_key': 'vk_api_key_setting',
|
185 |
'crypto_key_sys': 'crypto_key_sys_setting',
|
186 |
'senler_token': 'senler_token_setting',
|
|
|
191 |
}
|
192 |
|
193 |
def save_settings(settings_dict):
|
194 |
+
global vk_api_key_ser, crypto_key_sys_ser, senler_token_ser, wa_ak_ser, wa_api_key_ser, curators_ser, call_api_key
|
195 |
|
196 |
# Присваиваем значения из словаря соответствующим переменным
|
|
|
197 |
vk_api_key_ser = settings_dict.get('vk_api_key', '')
|
198 |
crypto_key_sys_ser = settings_dict.get('crypto_key_sys', '')
|
199 |
senler_token_ser = settings_dict.get('senler_token', '')
|
|
|
203 |
call_api_key = settings_dict.get('call_api_key', '')
|
204 |
|
205 |
print(f"Сохраненные настройки:")
|
|
|
206 |
print(f"vk_api_key: {vk_api_key_ser}")
|
207 |
print(f"crypto_key_sys: {crypto_key_sys_ser}")
|
208 |
print(f"senler_token: {senler_token_ser}")
|
|
|
213 |
|
214 |
@app.route('/load_settings', methods=['POST'])
|
215 |
def get_settings():
|
216 |
+
# Получаем ключ авторизации из запроса
|
217 |
+
client_api_key_sys = request.json.get('api_key_sys')
|
218 |
+
|
219 |
+
# Проверка ключа авторизации
|
220 |
+
if client_api_key_sys != api_key_sys:
|
221 |
return jsonify({"error": "Unauthorized access"}), 403
|
222 |
|
223 |
return jsonify(settings)
|
224 |
|
225 |
@app.route('/save_settings', methods=['POST'])
|
226 |
def save_settings_route():
|
227 |
+
# Получаем ключ авторизации из запроса
|
228 |
+
client_api_key_sys = request.json.get('api_key_sys')
|
229 |
+
|
230 |
+
# Проверка ключа авторизации
|
231 |
+
if client_api_key_sys != api_key_sys:
|
232 |
return jsonify({"error": "Unauthorized access"}), 403
|
233 |
|
234 |
data = request.json.get('data', {})
|
235 |
if data:
|
236 |
+
save_settings(data)
|
|
|
|
|
|
|
237 |
return jsonify({'status': 'success'})
|
238 |
else:
|
239 |
return jsonify({'status': 'error', 'message': 'No data provided'}), 400
|
240 |
|
|
|
241 |
@app.route('/set')
|
242 |
def index_set():
|
243 |
return render_template('settings.html')
|
|
|
251 |
|
252 |
|
253 |
|
254 |
+
|
255 |
+
|
256 |
mapping_template = {
|
257 |
"username": "name",
|
258 |
"phone": "phone",
|