Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -381,6 +381,46 @@ def add_user_home():
|
|
381 |
logging.error(f"Error adding user: {e}")
|
382 |
return jsonify({'status': 'error', 'message': str(e)}), 500
|
383 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
384 |
@app.route('/add_user_mess', methods=['GET'])
|
385 |
def add_user_mess():
|
386 |
global current_curator_index
|
|
|
381 |
logging.error(f"Error adding user: {e}")
|
382 |
return jsonify({'status': 'error', 'message': str(e)}), 500
|
383 |
|
384 |
+
@app.route('/user', methods=['GET'])
|
385 |
+
def user():
|
386 |
+
global current_curator_index
|
387 |
+
|
388 |
+
veref_on_off = request.args.get('ver', '0')
|
389 |
+
curator_on_off = request.args.get('cur', '0')
|
390 |
+
db_name = request.args.get('db', 'data_gc.db') # Получаем имя базы данных из запроса
|
391 |
+
|
392 |
+
template_key = request.args.get('player', 'site')
|
393 |
+
mapping_template_cur = mapp_templates.get(template_key, mt_site)
|
394 |
+
|
395 |
+
user_data = {mapping_template_cur[key]: request.args.get(key, "") for key in mapping_template_cur}
|
396 |
+
|
397 |
+
logging.debug(f"Received data: {user_data}")
|
398 |
+
|
399 |
+
if curator_on_off == "1":
|
400 |
+
user_data['curator'] = curators[current_curator_index]
|
401 |
+
current_curator_index = (current_curator_index + 1) % len(curators)
|
402 |
+
else:
|
403 |
+
user_data['curator'] = user_data.get('curator', '')
|
404 |
+
|
405 |
+
if veref_on_off == "1":
|
406 |
+
phone_number = user_data.get('phone', '')
|
407 |
+
if not phone_number:
|
408 |
+
logging.error("Phone number is empty")
|
409 |
+
return jsonify({'status': 'error', 'message': 'Phone number is empty'}), 400
|
410 |
+
|
411 |
+
phone_verification_response = verify_phone_number(phone_number)
|
412 |
+
if phone_verification_response is not None:
|
413 |
+
user_data['ws_st'] = '1' if phone_verification_response else '0'
|
414 |
+
else:
|
415 |
+
user_data['ws_st'] = user_data.get('ws_st', '')
|
416 |
+
|
417 |
+
try:
|
418 |
+
add_or_update_contact(user_data, db_name)
|
419 |
+
return jsonify({'status': 'success', 'message': f'User added {user_data.get("curator", "not assigned")}'})
|
420 |
+
except Exception as e:
|
421 |
+
logging.error(f"Error adding user: {e}")
|
422 |
+
return jsonify({'status': 'error', 'message': str(e)}), 500
|
423 |
+
|
424 |
@app.route('/add_user_mess', methods=['GET'])
|
425 |
def add_user_mess():
|
426 |
global current_curator_index
|