Update app.py
Browse files
app.py
CHANGED
|
@@ -93,7 +93,6 @@ for db in DATABASES:
|
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
-
# Функции для выполнения HTTP запросов
|
| 97 |
def fetch(url):
|
| 98 |
try:
|
| 99 |
response = requests.get(url)
|
|
@@ -104,16 +103,6 @@ def fetch(url):
|
|
| 104 |
print(f"Ошибка при выполнении GET запроса к {url}: {e}")
|
| 105 |
return None
|
| 106 |
|
| 107 |
-
def send_notification(url, data):
|
| 108 |
-
try:
|
| 109 |
-
response = requests.post(url, json=data)
|
| 110 |
-
response.raise_for_status()
|
| 111 |
-
print(f"POST запрос к {url} выполнен успешно.")
|
| 112 |
-
return response.json()
|
| 113 |
-
except requests.RequestException as e:
|
| 114 |
-
print(f"Ошибка при выполнении POST запроса к {url}: {e}")
|
| 115 |
-
return None
|
| 116 |
-
|
| 117 |
# Основная функция для отправки запросов
|
| 118 |
def send_requests():
|
| 119 |
global code_executed, export_id
|
|
@@ -126,7 +115,7 @@ def send_requests():
|
|
| 126 |
data = fetch(url_template)
|
| 127 |
if data and data.get("success"):
|
| 128 |
export_id = data.get("info", {}).get("export_id", "")
|
| 129 |
-
print("Export ID:", export_id)
|
| 130 |
|
| 131 |
# Отправка оповещения на другой сервер
|
| 132 |
notification_url = "https://skyauto.me/cllbck/217669590/29245685/bGZuMDRZZUpLZ3VJR2oxcC9CQmh0UT0?api=1&uid=535939344" # Замените на ваш URL
|
|
@@ -149,24 +138,14 @@ def send_requests():
|
|
| 149 |
def send_second_request(export_id):
|
| 150 |
if export_id is None:
|
| 151 |
raise Exception("export_id is None")
|
| 152 |
-
print(f"Отправка запроса с export_id: {export_id}") # Отладочное сообщение
|
| 153 |
# Формирование URL для второго запроса
|
| 154 |
export_url_template = f"{gc_url_export}/{export_id}?key={gc_api}"
|
| 155 |
try:
|
| 156 |
response = requests.get(export_url_template)
|
| 157 |
-
response.raise_for_status()
|
| 158 |
print("Ответ сервера:")
|
| 159 |
print(response.text) # Вывод ответа сервера в консоль сервера
|
| 160 |
-
|
| 161 |
-
# Попытка распарсить JSON
|
| 162 |
-
try:
|
| 163 |
-
json_response = response.json()
|
| 164 |
-
print("JSON ответ сервера:")
|
| 165 |
-
print(json_response)
|
| 166 |
-
except json.JSONDecodeError as e:
|
| 167 |
-
print(f"Ошибка при декодировании JSON: {e}")
|
| 168 |
-
print("Текст ответа, который не удалось распарсить:")
|
| 169 |
-
print(response.text)
|
| 170 |
except requests.RequestException as e:
|
| 171 |
print(f"Ошибка при выполнении запроса: {e}")
|
| 172 |
|
|
@@ -174,6 +153,8 @@ def send_second_request(export_id):
|
|
| 174 |
@app.route('/export_user', methods=['GET'])
|
| 175 |
def export_user():
|
| 176 |
try:
|
|
|
|
|
|
|
| 177 |
print("Вызов send_second_request") # Отладочное сообщение
|
| 178 |
send_second_request(export_id)
|
| 179 |
return "Запрос выполнен", 200
|
|
@@ -193,7 +174,6 @@ def export_user():
|
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
-
|
| 197 |
def load_data_from_json():
|
| 198 |
data = json.loads(json_data)
|
| 199 |
items = data['info']['items']
|
|
|
|
| 93 |
|
| 94 |
|
| 95 |
|
|
|
|
| 96 |
def fetch(url):
|
| 97 |
try:
|
| 98 |
response = requests.get(url)
|
|
|
|
| 103 |
print(f"Ошибка при выполнении GET запроса к {url}: {e}")
|
| 104 |
return None
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
# Основная функция для отправки запросов
|
| 107 |
def send_requests():
|
| 108 |
global code_executed, export_id
|
|
|
|
| 115 |
data = fetch(url_template)
|
| 116 |
if data and data.get("success"):
|
| 117 |
export_id = data.get("info", {}).get("export_id", "")
|
| 118 |
+
print("Export ID:", export_id) # Отладочное сообщение
|
| 119 |
|
| 120 |
# Отправка оповещения на другой сервер
|
| 121 |
notification_url = "https://skyauto.me/cllbck/217669590/29245685/bGZuMDRZZUpLZ3VJR2oxcC9CQmh0UT0?api=1&uid=535939344" # Замените на ваш URL
|
|
|
|
| 138 |
def send_second_request(export_id):
|
| 139 |
if export_id is None:
|
| 140 |
raise Exception("export_id is None")
|
| 141 |
+
print(f"Отправка второго запроса с export_id: {export_id}") # Отладочное сообщение
|
| 142 |
# Формирование URL для второго запроса
|
| 143 |
export_url_template = f"{gc_url_export}/{export_id}?key={gc_api}"
|
| 144 |
try:
|
| 145 |
response = requests.get(export_url_template)
|
| 146 |
+
response.raise_for_status()
|
| 147 |
print("Ответ сервера:")
|
| 148 |
print(response.text) # Вывод ответа сервера в консоль сервера
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
except requests.RequestException as e:
|
| 150 |
print(f"Ошибка при выполнении запроса: {e}")
|
| 151 |
|
|
|
|
| 153 |
@app.route('/export_user', methods=['GET'])
|
| 154 |
def export_user():
|
| 155 |
try:
|
| 156 |
+
print("Вызов send_requests") # Отладочное сообщение
|
| 157 |
+
send_requests()
|
| 158 |
print("Вызов send_second_request") # Отладочное сообщение
|
| 159 |
send_second_request(export_id)
|
| 160 |
return "Запрос выполнен", 200
|
|
|
|
| 174 |
|
| 175 |
|
| 176 |
|
|
|
|
| 177 |
def load_data_from_json():
|
| 178 |
data = json.loads(json_data)
|
| 179 |
items = data['info']['items']
|