DmitrMakeev
commited on
Commit
•
0c977bc
1
Parent(s):
d3774ee
Update app.py
Browse files
app.py
CHANGED
@@ -150,69 +150,37 @@ def start_mailings():
|
|
150 |
|
151 |
|
152 |
|
153 |
-
@app.route('/
|
154 |
-
def
|
155 |
try:
|
156 |
api_sys_control = request.args.get('api_sys')
|
157 |
|
158 |
if api_sys_control != api_key_sys:
|
159 |
return "EUR 22", 200
|
160 |
|
161 |
-
name = request.args.get('name')
|
162 |
-
phone = request.args.get('phone')
|
163 |
-
email = request.args.get('email')
|
164 |
-
vk_id = request.args.get('vk_id', '')
|
165 |
-
chat_id = request.args.get('chat_id', '')
|
166 |
-
ws_statys = request.args.get('ws_st', '')
|
167 |
-
ws_stop = request.args.get('ws_stop', '')
|
168 |
-
web_statys = request.args.get('web_st', 0, type=int)
|
169 |
-
fin_progress = request.args.get('fin_prog', 0, type=int)
|
170 |
-
shop_statys_full = request.args.get('shop_st', '')
|
171 |
-
pr1 = request.args.get('pr1', '')
|
172 |
-
pr2 = request.args.get('pr2', '')
|
173 |
-
pr3 = request.args.get('pr3', '')
|
174 |
-
pr4 = request.args.get('pr4', '')
|
175 |
-
pr5 = request.args.get('pr5', '')
|
176 |
-
ad_url = request.args.get('ad_url', '')
|
177 |
-
curator = request.args.get('curator', '')
|
178 |
-
|
179 |
-
if not name or not phone or not email:
|
180 |
-
return "Parameters 'name', 'phone', and 'email' are required.", 400
|
181 |
-
|
182 |
-
# Очистка номера телефона от плюса, если он есть
|
183 |
-
if phone.startswith('+'):
|
184 |
-
phone = phone[1:]
|
185 |
-
|
186 |
conn = sqlite3.connect('data_gc.db')
|
187 |
cursor = conn.cursor()
|
188 |
-
cursor.execute('
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
name = ?, email = ?, vk_id = ?, chat_id = ?, ws_statys = ?, ws_stop = ?,
|
195 |
-
web_statys = ?, fin_progress = ?, shop_statys_full = ?, pr1 = ?, pr2 = ?,
|
196 |
-
pr3 = ?, pr4 = ?, pr5 = ?, ad_url = ?, curator = ?
|
197 |
-
WHERE phone = ? OR email = ?
|
198 |
-
''', (name, email, vk_id, chat_id, ws_statys, ws_stop, web_statys, fin_progress,
|
199 |
-
shop_statys_full, pr1, pr2, pr3, pr4, pr5, ad_url, curator, phone, email))
|
200 |
-
else:
|
201 |
-
cursor.execute('''
|
202 |
-
INSERT INTO contacts (
|
203 |
-
name, phone, email, vk_id, chat_id, ws_statys, ws_stop, web_statys, fin_progress,
|
204 |
-
shop_statys_full, pr1, pr2, pr3, pr4, pr5, ad_url, curator
|
205 |
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
206 |
-
''', (name, phone, email, vk_id, chat_id, ws_statys, ws_stop, web_statys, fin_progress,
|
207 |
-
shop_statys_full, pr1, pr2, pr3, pr4, pr5, ad_url, curator))
|
208 |
-
|
209 |
-
conn.commit()
|
210 |
conn.close()
|
211 |
|
212 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
213 |
except Exception as e:
|
214 |
-
|
215 |
-
|
|
|
|
|
216 |
|
217 |
|
218 |
|
|
|
150 |
|
151 |
|
152 |
|
153 |
+
@app.route('/data_gc_tab_out', methods=['GET'])
|
154 |
+
def data_gc_tab_out():
|
155 |
try:
|
156 |
api_sys_control = request.args.get('api_sys')
|
157 |
|
158 |
if api_sys_control != api_key_sys:
|
159 |
return "EUR 22", 200
|
160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
conn = sqlite3.connect('data_gc.db')
|
162 |
cursor = conn.cursor()
|
163 |
+
cursor.execute('''
|
164 |
+
SELECT id, name, phone, email, vk_id, chat_id, ws_statys, ws_stop, web_statys, fin_progress,
|
165 |
+
shop_statys_full, pr1, pr2, pr3, pr4, pr5, ad_url, curator
|
166 |
+
FROM contacts
|
167 |
+
''')
|
168 |
+
contacts = cursor.fetchall()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
conn.close()
|
170 |
|
171 |
+
contacts_json = [{
|
172 |
+
'id': contact[0], 'name': contact[1], 'phone': contact[2], 'email': contact[3],
|
173 |
+
'vk_id': contact[4], 'chat_id': contact[5], 'ws_statys': contact[6], 'ws_stop': contact[7],
|
174 |
+
'web_statys': contact[8], 'fin_progress': contact[9], 'shop_statys_full': contact[10],
|
175 |
+
'pr1': contact[11], 'pr2': contact[12], 'pr3': contact[13], 'pr4': contact[14],
|
176 |
+
'pr5': contact[15], 'ad_url': contact[16], 'curator': contact[17]
|
177 |
+
} for contact in contacts]
|
178 |
+
return jsonify(contacts_json), 200
|
179 |
except Exception as e:
|
180 |
+
error_message = f"Error getting data from data_gc: {e}"
|
181 |
+
print(error_message)
|
182 |
+
return error_message, 500
|
183 |
+
|
184 |
|
185 |
|
186 |
|