DmitrMakeev
commited on
Commit
•
2dc0711
1
Parent(s):
8dbc575
Update app.py
Browse files
app.py
CHANGED
@@ -878,25 +878,30 @@ def update_or_insert_user(db_name, user_data, mapping_template):
|
|
878 |
@app.route('/send_request', methods=['POST'])
|
879 |
def send_request():
|
880 |
token = request.form.get('token')
|
881 |
-
|
882 |
-
|
883 |
limit = request.form.get('limit', 20)
|
884 |
-
|
885 |
-
|
886 |
-
url = f'https://online.bizon365.ru/api/v1/webinars
|
|
|
|
|
|
|
|
|
|
|
|
|
887 |
|
888 |
try:
|
889 |
-
response = requests.get(url, headers={'X-Token': token})
|
890 |
-
response.raise_for_status() #
|
891 |
-
|
892 |
data = response.json()
|
893 |
-
# Если возвращаемые данные не массив, например, если это объект, преобразуем его в массив
|
894 |
-
if not isinstance(data, list):
|
895 |
-
data = data.get('results', [])
|
896 |
-
return jsonify(data)
|
897 |
|
|
|
|
|
|
|
|
|
898 |
except requests.exceptions.RequestException as e:
|
899 |
-
return jsonify({'error': str(e)}), 500
|
900 |
|
901 |
|
902 |
|
|
|
878 |
@app.route('/send_request', methods=['POST'])
|
879 |
def send_request():
|
880 |
token = request.form.get('token')
|
881 |
+
min_date = request.form.get('minDate')
|
882 |
+
max_date = request.form.get('maxDate')
|
883 |
limit = request.form.get('limit', 20)
|
884 |
+
webinar_type = request.form.get('type')
|
885 |
+
|
886 |
+
url = f'https://online.bizon365.ru/api/v1/webinars'
|
887 |
+
params = {
|
888 |
+
'type': webinar_type,
|
889 |
+
'minDate': min_date,
|
890 |
+
'maxDate': max_date,
|
891 |
+
'limit': limit
|
892 |
+
}
|
893 |
|
894 |
try:
|
895 |
+
response = requests.get(url, headers={'X-Token': token}, params=params)
|
896 |
+
response.raise_for_status() # Проверка на статус ошибки
|
|
|
897 |
data = response.json()
|
|
|
|
|
|
|
|
|
898 |
|
899 |
+
# Проверка структуры ответа и извлечение данных
|
900 |
+
webinars = data.get('webinars', [])
|
901 |
+
return jsonify(webinars)
|
902 |
+
|
903 |
except requests.exceptions.RequestException as e:
|
904 |
+
return jsonify({'error': f'API request failed: {str(e)}'}), 500
|
905 |
|
906 |
|
907 |
|