Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ import time
|
|
| 7 |
import re
|
| 8 |
import json
|
| 9 |
import base64
|
| 10 |
-
|
| 11 |
|
| 12 |
from unidecode import unidecode
|
| 13 |
|
|
@@ -766,7 +766,20 @@ def send_get_request():
|
|
| 766 |
|
| 767 |
if response.status_code == 200:
|
| 768 |
data = response.json()
|
| 769 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 770 |
return jsonify(report)
|
| 771 |
else:
|
| 772 |
return jsonify({'error': 'Failed to fetch data from the API'}), response.status_code
|
|
|
|
| 7 |
import re
|
| 8 |
import json
|
| 9 |
import base64
|
| 10 |
+
import execjs
|
| 11 |
|
| 12 |
from unidecode import unidecode
|
| 13 |
|
|
|
|
| 766 |
|
| 767 |
if response.status_code == 200:
|
| 768 |
data = response.json()
|
| 769 |
+
|
| 770 |
+
# JavaScript код для извлечения поля "report"
|
| 771 |
+
js_code = f"""
|
| 772 |
+
function getReport(data) {{
|
| 773 |
+
return data.report;
|
| 774 |
+
}}
|
| 775 |
+
"""
|
| 776 |
+
|
| 777 |
+
# Компиляция JavaScript кода
|
| 778 |
+
ctx = execjs.compile(js_code)
|
| 779 |
+
|
| 780 |
+
# Вызов функции JavaScript для извлечения поля "report"
|
| 781 |
+
report = ctx.call("getReport", data)
|
| 782 |
+
|
| 783 |
return jsonify(report)
|
| 784 |
else:
|
| 785 |
return jsonify({'error': 'Failed to fetch data from the API'}), response.status_code
|