DmitrMakeev commited on
Commit
9250753
·
verified ·
1 Parent(s): e3d9e7e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -18
app.py CHANGED
@@ -116,13 +116,11 @@ for db in DATABASES:
116
 
117
 
118
 
119
- # Если start_up равна '1', выполним запросы
 
 
120
  if start_up == '1':
121
  # Ваши API-ключи и другие переменные
122
- gc_url_gru = os.getenv('gc_url_gru')
123
- gc_api = os.getenv('gc_api')
124
- gc_url_export = os.getenv('gc_url_export')
125
- id_gru = "2993783"
126
  date_from = "2022-01-01"
127
  status = "active"
128
 
@@ -133,16 +131,10 @@ if start_up == '1':
133
  response = requests.get(url_template)
134
 
135
  if response.status_code == 200:
136
- print("Первый запрос успешно выполнен")
137
  data = response.json()
138
-
139
  if data.get("success"):
140
  export_id = data.get("info", {}).get("export_id", "")
141
  print("Export ID:", export_id)
142
-
143
- # Задержка в 5 минут перед вторым запросом (в миллисекундах)
144
- time_delay = 1 * 60
145
- time.sleep(time_delay)
146
 
147
  # Формирование URL для второго запроса по export_id
148
  export_url_template = f"{gc_url_export}/{export_id}?key={gc_api}"
@@ -151,22 +143,22 @@ if start_up == '1':
151
  export_response = requests.get(export_url_template)
152
 
153
  if export_response.status_code == 200:
154
- print("Второй запрос по export_id успешно выполнен")
155
  export_data = export_response.json()
156
  print("Полученные данные по export_id:", export_data)
 
157
  else:
158
- print("Ошибка при выполнении второго запроса по export_id")
159
- print("Статус код:", export_response.status_code)
160
- print("Ответ:", export_response.text)
161
  else:
162
  print("Ошибка в ответе от сервера:", data.get("error_message"))
163
  else:
164
- print("Ошибка при выполнении первого запроса")
165
- print("Статус код:", response.status_code)
166
  else:
167
  print("Системная переменная start_up не равна '1', код не выполняется при старте сервера.")
168
 
169
-
 
 
 
170
 
171
 
172
 
 
116
 
117
 
118
 
119
+ # Переменная для проверки выполнения кода
120
+ code_executed = False
121
+
122
  if start_up == '1':
123
  # Ваши API-ключи и другие переменные
 
 
 
 
124
  date_from = "2022-01-01"
125
  status = "active"
126
 
 
131
  response = requests.get(url_template)
132
 
133
  if response.status_code == 200:
 
134
  data = response.json()
 
135
  if data.get("success"):
136
  export_id = data.get("info", {}).get("export_id", "")
137
  print("Export ID:", export_id)
 
 
 
 
138
 
139
  # Формирование URL для второго запроса по export_id
140
  export_url_template = f"{gc_url_export}/{export_id}?key={gc_api}"
 
143
  export_response = requests.get(export_url_template)
144
 
145
  if export_response.status_code == 200:
 
146
  export_data = export_response.json()
147
  print("Полученные данные по export_id:", export_data)
148
+ code_executed = True # Устанавливаем флаг выполнения кода
149
  else:
150
+ print(f"Ошибка при выполнении второго запроса по export_id, статус код: {export_response.status_code}")
 
 
151
  else:
152
  print("Ошибка в ответе от сервера:", data.get("error_message"))
153
  else:
154
+ print(f"Ошибка при выполнении первого запроса, статус код: {response.status_code}")
 
155
  else:
156
  print("Системная переменная start_up не равна '1', код не выполняется при старте сервера.")
157
 
158
+ # Обработчик корневого маршрута, который никогда не будет вызван
159
+ @app.route('/')
160
+ def index():
161
+ return jsonify({"message": "Этот маршрут не должен быть вызван"})
162
 
163
 
164