DmitrMakeev
commited on
Commit
•
c5fc451
1
Parent(s):
9565f93
Update app.py
Browse files
app.py
CHANGED
@@ -220,6 +220,9 @@ def export_user():
|
|
220 |
|
221 |
|
222 |
def load_data_from_json(json_data):
|
|
|
|
|
|
|
223 |
if 'info' not in json_data or 'items' not in json_data['info'] or 'fields' not in json_data['info']:
|
224 |
raise ValueError("Invalid JSON structure")
|
225 |
|
@@ -258,6 +261,7 @@ def load_data_from_json(json_data):
|
|
258 |
user_data.setdefault('n_con', '')
|
259 |
user_data.setdefault('canal', '')
|
260 |
user_data.setdefault('data_t', '')
|
|
|
261 |
# Убираем плюс в начале телефона, если он присутствует
|
262 |
if 'Телефон' in user_data and user_data['Телефон'].startswith('+'):
|
263 |
user_data['Телефон'] = user_data['Телефон'][1:]
|
@@ -294,6 +298,7 @@ def load_data_from_json(json_data):
|
|
294 |
|
295 |
|
296 |
|
|
|
297 |
|
298 |
|
299 |
def send_second_request(export_id):
|
@@ -306,6 +311,7 @@ def send_second_request(export_id):
|
|
306 |
else:
|
307 |
raise Exception(f"Failed to fetch data, status code: {response.status_code}")
|
308 |
|
|
|
309 |
@app.route('/start', methods=['GET'])
|
310 |
def start():
|
311 |
export_id = request.args.get('export_id')
|
@@ -319,6 +325,7 @@ def start():
|
|
319 |
|
320 |
try:
|
321 |
json_data = send_second_request(export_id)
|
|
|
322 |
load_data_from_json(json_data)
|
323 |
return "Data loaded successfully", 200
|
324 |
except Exception as e:
|
@@ -327,6 +334,7 @@ def start():
|
|
327 |
|
328 |
|
329 |
|
|
|
330 |
|
331 |
def randomize_message(template):
|
332 |
def replace_placeholder(match):
|
|
|
220 |
|
221 |
|
222 |
def load_data_from_json(json_data):
|
223 |
+
# Debug print to inspect json_data
|
224 |
+
print(json.dumps(json_data, indent=4, ensure_ascii=False))
|
225 |
+
|
226 |
if 'info' not in json_data or 'items' not in json_data['info'] or 'fields' not in json_data['info']:
|
227 |
raise ValueError("Invalid JSON structure")
|
228 |
|
|
|
261 |
user_data.setdefault('n_con', '')
|
262 |
user_data.setdefault('canal', '')
|
263 |
user_data.setdefault('data_t', '')
|
264 |
+
|
265 |
# Убираем плюс в начале телефона, если он присутствует
|
266 |
if 'Телефон' in user_data and user_data['Телефон'].startswith('+'):
|
267 |
user_data['Телефон'] = user_data['Телефон'][1:]
|
|
|
298 |
|
299 |
|
300 |
|
301 |
+
|
302 |
|
303 |
|
304 |
def send_second_request(export_id):
|
|
|
311 |
else:
|
312 |
raise Exception(f"Failed to fetch data, status code: {response.status_code}")
|
313 |
|
314 |
+
|
315 |
@app.route('/start', methods=['GET'])
|
316 |
def start():
|
317 |
export_id = request.args.get('export_id')
|
|
|
325 |
|
326 |
try:
|
327 |
json_data = send_second_request(export_id)
|
328 |
+
print(json.dumps(json_data, indent=4, ensure_ascii=False)) # Debug print to inspect JSON data received
|
329 |
load_data_from_json(json_data)
|
330 |
return "Data loaded successfully", 200
|
331 |
except Exception as e:
|
|
|
334 |
|
335 |
|
336 |
|
337 |
+
|
338 |
|
339 |
def randomize_message(template):
|
340 |
def replace_placeholder(match):
|