DmitrMakeev commited on
Commit
241d9c7
1 Parent(s): d64a634

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -10
app.py CHANGED
@@ -1838,6 +1838,13 @@ DATABASES5 = ['data_gc.db']
1838
  curators = ["Anna", "Ekaterina", "Ivan", "Maria", "Sergey", "Olga", "Alex", "Natalia", "Dmitry", "Elena"]
1839
  current_curator_index = 0
1840
 
 
 
 
 
 
 
 
1841
  def j_verify_phone_number(phone_number):
1842
  full_url_ver = f"{wa_url}{wa_ak}{ws_url_ver}{wa_api_key}"
1843
  payload = {"phoneNumber": phone_number}
@@ -1919,15 +1926,17 @@ def j_upload_json():
1919
  if file.filename == '':
1920
  return jsonify({"error": "No selected file"}), 400
1921
  if file and file.filename.endswith('.json'):
1922
- stream = io.StringIO(file.stream.read().decode("UTF8"), newline=None)
1923
- data = stream.getvalue()
1924
- parsed_data = j_parse_json_data(data)
1925
- verify_phone = request.form.get('verify_phone', '0')
1926
- add_curator = request.form.get('add_curator', '0')
1927
- logging.debug(f"Verify Phone: {verify_phone}")
1928
- logging.debug(f"Add Curator: {add_curator}")
1929
- j_insert_data(parsed_data, verify_phone, add_curator)
1930
- return jsonify({"message": "Data uploaded and inserted successfully"})
 
 
1931
  return jsonify({"error": "Invalid file format"}), 400
1932
 
1933
  @app.route('/j_upl_json', methods=['GET'])
@@ -1960,7 +1969,6 @@ def j_se_upl_json():
1960
 
1961
 
1962
 
1963
-
1964
 
1965
 
1966
  @app.route('/gc_in', methods=['GET'])
 
1838
  curators = ["Anna", "Ekaterina", "Ivan", "Maria", "Sergey", "Olga", "Alex", "Natalia", "Dmitry", "Elena"]
1839
  current_curator_index = 0
1840
 
1841
+ wa_url = 'https://example.com'
1842
+ wa_ak = 'API_KEY'
1843
+ ws_url_ver = '/verify_phone'
1844
+ wa_api_key = 'YOUR_API_KEY'
1845
+ gog_url = 'https://example.com/google_forms'
1846
+ api_key_sys = 'YOUR_API_KEY_SYS'
1847
+
1848
  def j_verify_phone_number(phone_number):
1849
  full_url_ver = f"{wa_url}{wa_ak}{ws_url_ver}{wa_api_key}"
1850
  payload = {"phoneNumber": phone_number}
 
1926
  if file.filename == '':
1927
  return jsonify({"error": "No selected file"}), 400
1928
  if file and file.filename.endswith('.json'):
1929
+ try:
1930
+ data = file.read().decode("UTF8")
1931
+ parsed_data = j_parse_json_data(data)
1932
+ verify_phone = request.form.get('verify_phone', '0')
1933
+ add_curator = request.form.get('add_curator', '0')
1934
+ logging.debug(f"Verify Phone: {verify_phone}")
1935
+ logging.debug(f"Add Curator: {add_curator}")
1936
+ j_insert_data(parsed_data, verify_phone, add_curator)
1937
+ return jsonify({"message": "Data uploaded and inserted successfully"})
1938
+ except json.JSONDecodeError as e:
1939
+ return jsonify({"error": "Invalid JSON format"}), 400
1940
  return jsonify({"error": "Invalid file format"}), 400
1941
 
1942
  @app.route('/j_upl_json', methods=['GET'])
 
1969
 
1970
 
1971
 
 
1972
 
1973
 
1974
  @app.route('/gc_in', methods=['GET'])