Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1767,13 +1767,9 @@ def display_form():
|
|
| 1767 |
DATABASE6 = 'data_gc.db'
|
| 1768 |
|
| 1769 |
|
| 1770 |
-
# Функция для очистки номера телефона
|
| 1771 |
-
def clean_phone_number_ss(phone_number):
|
| 1772 |
-
return re.sub(r'\D', '', phone_number)
|
| 1773 |
-
|
| 1774 |
# Функция для вставки данных в базу данных
|
| 1775 |
def insert_data_ss(data):
|
| 1776 |
-
conn = sqlite3.connect(DATABASE6)
|
| 1777 |
cursor = conn.cursor()
|
| 1778 |
|
| 1779 |
for row in data:
|
|
@@ -1782,7 +1778,6 @@ def insert_data_ss(data):
|
|
| 1782 |
email = row.get('email', '')
|
| 1783 |
data_t = row.get('data_t', '').strip('"')
|
| 1784 |
|
| 1785 |
-
# Очистка номера телефона
|
| 1786 |
phone = clean_phone_number_ss(phone)
|
| 1787 |
|
| 1788 |
cursor.execute("SELECT 1 FROM contacts WHERE email = ? OR phone = ?", (email, phone))
|
|
@@ -1795,7 +1790,6 @@ def insert_data_ss(data):
|
|
| 1795 |
columns = ['name', 'phone', 'email', 'vk_id', 'chat_id', 'ws_st', 'ws_stop', 'web_st', 'fin_prog', 'b_city', 'b_fin', 'b_ban', 'b_ign', 'b_baners', 'b_butt', 'b_mess', 'shop_st', 'curator', 'pr1', 'pr2', 'pr3', 'pr4', 'pr5', 'gc_url', 'key_pr', 'n_con', 'canal', 'data_on', 'data_t', 'utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'gcpc']
|
| 1796 |
values = [name, phone, email, row.get('vk_id', ''), row.get('chat_id', ''), row.get('ws_st', ''), row.get('ws_stop', ''), row.get('web_st', 0), row.get('fin_prog', 0), row.get('b_city', ''), row.get('b_fin', ''), row.get('b_ban', ''), row.get('b_ign', ''), row.get('b_baners', ''), row.get('b_butt', ''), row.get('b_mess', ''), row.get('shop_st', ''), row.get('curator', ''), row.get('pr1', ''), row.get('pr2', ''), row.get('pr3', ''), row.get('pr4', ''), row.get('pr5', ''), row.get('gc_url', ''), row.get('key_pr', ''), row.get('n_con', ''), row.get('canal', ''), row.get('data_on', ''), row.get('data_t', ''), row.get('utm_source', ''), row.get('utm_medium', ''), row.get('utm_campaign', ''), row.get('utm_term', ''), row.get('utm_content', ''), row.get('gcpc', '')]
|
| 1797 |
|
| 1798 |
-
# Исключение столбцов
|
| 1799 |
excluded_columns = ['vk_id', 'chat_id', 'ws_st', 'ws_stop', 'web_st', 'fin_prog', 'b_city', 'b_fin', 'b_ban', 'b_ign', 'b_baners', 'b_butt', 'b_mess', 'shop_st', 'curator', 'pr1', 'pr2', 'pr3', 'pr4', 'pr5', 'gc_url', 'key_pr', 'n_con', 'canal', 'data_on', 'data_t', 'utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'gcpc']
|
| 1800 |
columns = [col for col in columns if col not in excluded_columns]
|
| 1801 |
values = [values[columns.index(col)] for col in columns]
|
|
@@ -1837,7 +1831,6 @@ def from_shop_st():
|
|
| 1837 |
if not email or not phone:
|
| 1838 |
return jsonify({"error": "Email and phone are required"}), 400
|
| 1839 |
|
| 1840 |
-
# Очистка номера телефона
|
| 1841 |
phone = clean_phone_number_ss(phone)
|
| 1842 |
|
| 1843 |
conn = sqlite3.connect(DATABASE6)
|
|
@@ -1866,7 +1859,6 @@ def from_shop_st():
|
|
| 1866 |
|
| 1867 |
shop_st_json = json.dumps(shop_st_data)
|
| 1868 |
|
| 1869 |
-
# Исключение столбцов
|
| 1870 |
excluded_columns = ['b_ban', 'b_baners', 'b_butt', 'b_city', 'b_fin', 'b_ign', 'b_mess', 'canal', 'chat_id', 'curator', 'data_on', 'data_t', 'fin_prog', 'gc_url', 'gcpc', 'key_pr', 'n_con', 'pr1', 'pr2', 'pr3', 'pr4', 'pr5', 'utm_campaign', 'utm_content', 'utm_medium', 'utm_source', 'utm_term', 'vk_id', 'web_st', 'ws_st', 'ws_stop']
|
| 1871 |
update_values = [name, phone, email, shop_st_json]
|
| 1872 |
update_columns = ['name', 'phone', 'email', 'shop_st']
|
|
@@ -1954,6 +1946,7 @@ def from_shop_st():
|
|
| 1954 |
|
| 1955 |
|
| 1956 |
|
|
|
|
| 1957 |
|
| 1958 |
|
| 1959 |
@app.route('/gc_in', methods=['GET'])
|
|
|
|
| 1767 |
DATABASE6 = 'data_gc.db'
|
| 1768 |
|
| 1769 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1770 |
# Функция для вставки данных в базу данных
|
| 1771 |
def insert_data_ss(data):
|
| 1772 |
+
conn = sqlite3.connect(DATABASE6)
|
| 1773 |
cursor = conn.cursor()
|
| 1774 |
|
| 1775 |
for row in data:
|
|
|
|
| 1778 |
email = row.get('email', '')
|
| 1779 |
data_t = row.get('data_t', '').strip('"')
|
| 1780 |
|
|
|
|
| 1781 |
phone = clean_phone_number_ss(phone)
|
| 1782 |
|
| 1783 |
cursor.execute("SELECT 1 FROM contacts WHERE email = ? OR phone = ?", (email, phone))
|
|
|
|
| 1790 |
columns = ['name', 'phone', 'email', 'vk_id', 'chat_id', 'ws_st', 'ws_stop', 'web_st', 'fin_prog', 'b_city', 'b_fin', 'b_ban', 'b_ign', 'b_baners', 'b_butt', 'b_mess', 'shop_st', 'curator', 'pr1', 'pr2', 'pr3', 'pr4', 'pr5', 'gc_url', 'key_pr', 'n_con', 'canal', 'data_on', 'data_t', 'utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'gcpc']
|
| 1791 |
values = [name, phone, email, row.get('vk_id', ''), row.get('chat_id', ''), row.get('ws_st', ''), row.get('ws_stop', ''), row.get('web_st', 0), row.get('fin_prog', 0), row.get('b_city', ''), row.get('b_fin', ''), row.get('b_ban', ''), row.get('b_ign', ''), row.get('b_baners', ''), row.get('b_butt', ''), row.get('b_mess', ''), row.get('shop_st', ''), row.get('curator', ''), row.get('pr1', ''), row.get('pr2', ''), row.get('pr3', ''), row.get('pr4', ''), row.get('pr5', ''), row.get('gc_url', ''), row.get('key_pr', ''), row.get('n_con', ''), row.get('canal', ''), row.get('data_on', ''), row.get('data_t', ''), row.get('utm_source', ''), row.get('utm_medium', ''), row.get('utm_campaign', ''), row.get('utm_term', ''), row.get('utm_content', ''), row.get('gcpc', '')]
|
| 1792 |
|
|
|
|
| 1793 |
excluded_columns = ['vk_id', 'chat_id', 'ws_st', 'ws_stop', 'web_st', 'fin_prog', 'b_city', 'b_fin', 'b_ban', 'b_ign', 'b_baners', 'b_butt', 'b_mess', 'shop_st', 'curator', 'pr1', 'pr2', 'pr3', 'pr4', 'pr5', 'gc_url', 'key_pr', 'n_con', 'canal', 'data_on', 'data_t', 'utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'gcpc']
|
| 1794 |
columns = [col for col in columns if col not in excluded_columns]
|
| 1795 |
values = [values[columns.index(col)] for col in columns]
|
|
|
|
| 1831 |
if not email or not phone:
|
| 1832 |
return jsonify({"error": "Email and phone are required"}), 400
|
| 1833 |
|
|
|
|
| 1834 |
phone = clean_phone_number_ss(phone)
|
| 1835 |
|
| 1836 |
conn = sqlite3.connect(DATABASE6)
|
|
|
|
| 1859 |
|
| 1860 |
shop_st_json = json.dumps(shop_st_data)
|
| 1861 |
|
|
|
|
| 1862 |
excluded_columns = ['b_ban', 'b_baners', 'b_butt', 'b_city', 'b_fin', 'b_ign', 'b_mess', 'canal', 'chat_id', 'curator', 'data_on', 'data_t', 'fin_prog', 'gc_url', 'gcpc', 'key_pr', 'n_con', 'pr1', 'pr2', 'pr3', 'pr4', 'pr5', 'utm_campaign', 'utm_content', 'utm_medium', 'utm_source', 'utm_term', 'vk_id', 'web_st', 'ws_st', 'ws_stop']
|
| 1863 |
update_values = [name, phone, email, shop_st_json]
|
| 1864 |
update_columns = ['name', 'phone', 'email', 'shop_st']
|
|
|
|
| 1946 |
|
| 1947 |
|
| 1948 |
|
| 1949 |
+
|
| 1950 |
|
| 1951 |
|
| 1952 |
@app.route('/gc_in', methods=['GET'])
|