DmitrMakeev commited on
Commit
be09f91
1 Parent(s): 74c7798

Update google_db.py

Browse files
Files changed (1) hide show
  1. google_db.py +23 -16
google_db.py CHANGED
@@ -12,12 +12,22 @@ def save_db():
12
 
13
  if api_key == request.args.get('api'):
14
  # Получаем данные из глобальных переменных
15
- names = request.args.get('name')
16
- emails = request.args.get('email')
17
- phones = request.args.get('phone')
18
- grups_id = request.args.get('grup_id')
19
- pr1s = request.args.get('pr1')
20
- pr2s = request.args.get('pr2')
 
 
 
 
 
 
 
 
 
 
21
 
22
  # Создаем данные для отправки
23
  data = {
@@ -44,21 +54,18 @@ def save_db():
44
  # Проверяем статус ответа
45
  if response.status_code == 200:
46
  err = 1
 
47
  else:
 
48
  err = 0
49
- response_data = {
50
- "status": "error",
51
- "err": err,
52
- "message": "Operation failed",
53
- "server_response": globs.server_response
54
- }
55
- return jsonify(response_data)
56
 
57
  response_data = {
58
  "status": "success" if err == 1 else "error",
59
  "err": err,
60
- "message": "Operation completed successfully" if err == 1 else "Operation failed",
61
- "server_response": globs.server_response
62
  }
63
 
64
- return jsonify(response_data)
 
12
 
13
  if api_key == request.args.get('api'):
14
  # Получаем данные из глобальных переменных
15
+ names = globs.name
16
+ emails = globs.email
17
+ phones = globs.phone
18
+ grups_id = globs.grup_id # Это List ID
19
+ pr1s = globs.pr1
20
+ pr2s = globs.pr2
21
+
22
+ # Проверка значений переменных
23
+ if not all([names, emails, phones, grups_id, pr1s, pr2s]):
24
+ response_data = {
25
+ "status": "error",
26
+ "err": 0,
27
+ "message": "Some required data is missing",
28
+ "server_response": None
29
+ }
30
+ return jsonify(response_data)
31
 
32
  # Создаем данные для отправки
33
  data = {
 
54
  # Проверяем статус ответа
55
  if response.status_code == 200:
56
  err = 1
57
+ response_message = "Operation completed successfully"
58
  else:
59
+ response_message = f"Error: {response.status_code} - {response.text}"
60
  err = 0
61
+ else:
62
+ response_message = "Invalid API key"
 
 
 
 
 
63
 
64
  response_data = {
65
  "status": "success" if err == 1 else "error",
66
  "err": err,
67
+ "message": response_message,
68
+ "server_response": globs.server_response if err == 1 else None
69
  }
70
 
71
+ return jsonify(response_data)