DmitrMakeev commited on
Commit
4987565
·
verified ·
1 Parent(s): 7f68151

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -240,7 +240,7 @@ def load_data_from_json(json_data):
240
  user_data.setdefault('ad_url', '')
241
  user_data.setdefault('key_pr', '')
242
  user_data.setdefault('canal', '')
243
- user_data.setdefault('data_t', '')
244
 
245
  # Убираем плюс в начале телефона, если он присутствует
246
  if 'Телефон' in user_data and user_data['Телефон'].startswith('+'):
@@ -248,9 +248,9 @@ def load_data_from_json(json_data):
248
 
249
  query = '''
250
  INSERT INTO contacts (
251
- name, phone, email, vk_id, chat_id, ws_statys, ws_stop, web_statys, fin_progress, shop_statys_full, pr1, pr2, pr3, pr4, pr5, ad_url, curator, key_pr, canal, data_t
252
  ) VALUES (
253
- :Имя, :Телефон, :Email, :vk_id, :chat_id, :ws_st, :ws_stop, :web_st, :fin_prog, :shop_st, :pr1, :pr2, :pr3, :pr4, :pr5, :ad_url, :curator, :key_pr, :canal, :data_t
254
  )
255
  '''
256
  cursor.execute(query, user_data)
@@ -264,18 +264,17 @@ def start():
264
  api_key_sys_control = request.args.get('api_sys')
265
 
266
  if export_id is None:
267
- return json.dumps({"error": "export_id is required"}), 400
268
 
269
  if api_key_sys_control != api_key_sys:
270
- return json.dumps({"error": "Unauthorized access"}), 403
271
 
272
  try:
273
  json_data = send_second_request(export_id)
274
  load_data_from_json(json_data)
275
  return "Data loaded successfully", 200
276
  except Exception as e:
277
- return json.dumps({"error": str(e)}), 500
278
-
279
 
280
 
281
 
 
240
  user_data.setdefault('ad_url', '')
241
  user_data.setdefault('key_pr', '')
242
  user_data.setdefault('canal', '')
243
+ user_data.setdefault('data_t', '')
244
 
245
  # Убираем плюс в начале телефона, если он присутствует
246
  if 'Телефон' in user_data and user_data['Телефон'].startswith('+'):
 
248
 
249
  query = '''
250
  INSERT INTO contacts (
251
+ name, phone, email, vk_id, chat_id, ws_statys, ws_stop, web_statys, fin_progress, shop_statys_full, pr1, pr2, pr3, pr4, pr5, ad_url, curator, key_pr, canal, data_t
252
  ) VALUES (
253
+ :Имя, :Телефон, :Email, :vk_id, :chat_id, :ws_st, :ws_stop, :web_st, :fin_prog, :shop_st, :pr1, :pr2, :pr3, :pr4, :pr5, :ad_url, :curator, :key_pr, :canal, :data_t
254
  )
255
  '''
256
  cursor.execute(query, user_data)
 
264
  api_key_sys_control = request.args.get('api_sys')
265
 
266
  if export_id is None:
267
+ return jsonify({"error": "export_id is required"}), 400
268
 
269
  if api_key_sys_control != api_key_sys:
270
+ return jsonify({"error": "Unauthorized access"}), 403
271
 
272
  try:
273
  json_data = send_second_request(export_id)
274
  load_data_from_json(json_data)
275
  return "Data loaded successfully", 200
276
  except Exception as e:
277
+ return jsonify({"error": str(e)}), 500
 
278
 
279
 
280