DmitrMakeev commited on
Commit
72e4d66
1 Parent(s): e653f44

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -1840,6 +1840,7 @@ current_curator_index = 0
1840
 
1841
 
1842
 
 
1843
  def j_verify_phone_number(phone_number):
1844
  full_url_ver = f"{wa_url}{wa_ak}{ws_url_ver}{wa_api_key}"
1845
  payload = {"phoneNumber": phone_number}
@@ -1851,13 +1852,14 @@ def j_verify_phone_number(phone_number):
1851
  else:
1852
  return "Error"
1853
 
 
1854
  def j_clean_phone_number(phone_number):
1855
- # Удаляем все символы, кроме цифр
1856
  return re.sub(r'\D', '', phone_number)
1857
 
 
1858
  def j_insert_data(data, verify_phone, add_curator):
1859
  global current_curator_index
1860
- conn = sqlite3.connect(DATABASE5) # Подключение к базе данных
1861
  cursor = conn.cursor()
1862
 
1863
  for row in data:
@@ -1912,6 +1914,7 @@ def j_insert_data(data, verify_phone, add_curator):
1912
  conn.commit()
1913
  conn.close()
1914
 
 
1915
  def send_to_google_forms(user_data, gog_url):
1916
  headers = {'Content-Type': 'application/json'}
1917
  response = requests.post(gog_url, headers=headers, json=user_data)
@@ -1919,6 +1922,7 @@ def send_to_google_forms(user_data, gog_url):
1919
  print(f"Failed to send data to Google Forms. Status code: {response.status_code}")
1920
  print(f"Response: {response.text}")
1921
 
 
1922
  @app.route('/upload_json', methods=['POST'])
1923
  def j_upload_json():
1924
  if 'file' not in request.files:
@@ -1936,6 +1940,7 @@ def j_upload_json():
1936
  return jsonify({"message": "Data uploaded and inserted successfully"})
1937
  return jsonify({"error": "Invalid file format"}), 400
1938
 
 
1939
  @app.route('/upl_json', methods=['GET'])
1940
  def j_se_upl_json():
1941
  api_sys_control = request.args.get('api_sys')
@@ -1962,7 +1967,6 @@ def j_se_upl_json():
1962
 
1963
 
1964
 
1965
-
1966
 
1967
 
1968
  @app.route('/gc_in', methods=['GET'])
 
1840
 
1841
 
1842
 
1843
+ # Функция для проверки номера телефона через API
1844
  def j_verify_phone_number(phone_number):
1845
  full_url_ver = f"{wa_url}{wa_ak}{ws_url_ver}{wa_api_key}"
1846
  payload = {"phoneNumber": phone_number}
 
1852
  else:
1853
  return "Error"
1854
 
1855
+ # Функция для очистки номера телефона
1856
  def j_clean_phone_number(phone_number):
 
1857
  return re.sub(r'\D', '', phone_number)
1858
 
1859
+ # Функция для вставки данных в базу данных
1860
  def j_insert_data(data, verify_phone, add_curator):
1861
  global current_curator_index
1862
+ conn = sqlite3.connect(DATABASE5) # Подключаемся к базе данных
1863
  cursor = conn.cursor()
1864
 
1865
  for row in data:
 
1914
  conn.commit()
1915
  conn.close()
1916
 
1917
+ # Функция для отправки данных в Google Forms
1918
  def send_to_google_forms(user_data, gog_url):
1919
  headers = {'Content-Type': 'application/json'}
1920
  response = requests.post(gog_url, headers=headers, json=user_data)
 
1922
  print(f"Failed to send data to Google Forms. Status code: {response.status_code}")
1923
  print(f"Response: {response.text}")
1924
 
1925
+ # Маршрут для загрузки JSON-файла
1926
  @app.route('/upload_json', methods=['POST'])
1927
  def j_upload_json():
1928
  if 'file' not in request.files:
 
1940
  return jsonify({"message": "Data uploaded and inserted successfully"})
1941
  return jsonify({"error": "Invalid file format"}), 400
1942
 
1943
+ # Маршрут для отображения формы загрузки JSON
1944
  @app.route('/upl_json', methods=['GET'])
1945
  def j_se_upl_json():
1946
  api_sys_control = request.args.get('api_sys')
 
1967
 
1968
 
1969
 
 
1970
 
1971
 
1972
  @app.route('/gc_in', methods=['GET'])