DmitrMakeev
commited on
Commit
•
f9bb068
1
Parent(s):
aed6774
Update app.py
Browse files
app.py
CHANGED
@@ -878,22 +878,25 @@ 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 |
-
minDate = request.form.get('minDate')
|
882 |
-
maxDate = request.form.get('maxDate')
|
883 |
limit = request.form.get('limit', 20)
|
884 |
type = request.form.get('type', 'LiveWebinars')
|
885 |
|
886 |
-
# Создание URL с параметрами
|
887 |
url = f'https://online.bizon365.ru/api/v1/webinars?type={type}&minDate={minDate}&maxDate={maxDate}&limit={limit}'
|
888 |
|
889 |
-
|
|
|
|
|
890 |
|
891 |
-
if response.status_code == 200:
|
892 |
data = response.json()
|
893 |
-
#
|
|
|
|
|
894 |
return jsonify(data)
|
895 |
-
|
896 |
-
|
|
|
897 |
|
898 |
|
899 |
|
|
|
878 |
@app.route('/send_request', methods=['POST'])
|
879 |
def send_request():
|
880 |
token = request.form.get('token')
|
881 |
+
minDate = request.form.get('minDate', '2020-01-01')
|
882 |
+
maxDate = request.form.get('maxDate', '2024-12-31')
|
883 |
limit = request.form.get('limit', 20)
|
884 |
type = request.form.get('type', 'LiveWebinars')
|
885 |
|
|
|
886 |
url = f'https://online.bizon365.ru/api/v1/webinars?type={type}&minDate={minDate}&maxDate={maxDate}&limit={limit}'
|
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 |
|