Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -156,42 +156,53 @@ def add_data_gc():
|
|
| 156 |
name = request.args.get('name')
|
| 157 |
phone = request.args.get('phone')
|
| 158 |
email = request.args.get('email')
|
| 159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
|
| 161 |
if not name or not phone or not email:
|
| 162 |
return "Parameters 'name', 'phone', and 'email' are required.", 400
|
| 163 |
|
| 164 |
-
if api_sys_control != api_key_sys:
|
| 165 |
-
return "EUR 22", 200
|
| 166 |
-
|
| 167 |
-
# Проверка и удаление плюса в начале номера телефона, если он есть
|
| 168 |
-
if phone.startswith('+'):
|
| 169 |
-
phone = phone[1:]
|
| 170 |
-
|
| 171 |
conn = sqlite3.connect('data_gc.db')
|
| 172 |
cursor = conn.cursor()
|
| 173 |
cursor.execute('SELECT * FROM contacts WHERE phone = ? OR email = ?', (phone, email))
|
| 174 |
existing_contact = cursor.fetchone()
|
| 175 |
|
| 176 |
if existing_contact:
|
| 177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
|
| 179 |
-
cursor.execute('''
|
| 180 |
-
INSERT INTO contacts (
|
| 181 |
-
name, phone, email, vk_id, chat_id, ws_statys, ws_stop, web_statys, fin_progress,
|
| 182 |
-
shop_statys_full, curator, shop_statys_cur, partner, pr1, pr2, pr3, pr4, pr5, ad_url
|
| 183 |
-
)
|
| 184 |
-
VALUES (?, ?, ?, '', '', '', '', 0, 0, '', '', '', '', '', '', '', '', '', '')
|
| 185 |
-
''', (name, phone, email))
|
| 186 |
conn.commit()
|
| 187 |
conn.close()
|
| 188 |
|
| 189 |
-
return f"Contact added: {name} - {phone} - {email}", 200
|
| 190 |
except Exception as e:
|
| 191 |
-
print(f"Error adding contact: {e}")
|
| 192 |
return "Internal Server Error", 500
|
| 193 |
-
|
| 194 |
-
|
| 195 |
|
| 196 |
|
| 197 |
|
|
@@ -201,29 +212,62 @@ def add_contact():
|
|
| 201 |
name = request.args.get('name')
|
| 202 |
phone = request.args.get('phone')
|
| 203 |
email = request.args.get('email')
|
| 204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
|
| 206 |
if not name or not phone or not email:
|
| 207 |
return "Parameters 'name', 'phone', and 'email' are required.", 400
|
| 208 |
|
| 209 |
-
if api_sys_control != api_key_sys:
|
| 210 |
-
return "EUR 22", 200
|
| 211 |
-
|
| 212 |
-
# Проверка и удаление плюса в начале номера телефона, если он есть
|
| 213 |
-
if phone.startswith('+'):
|
| 214 |
-
phone = phone[1:]
|
| 215 |
-
|
| 216 |
conn = sqlite3.connect('data1.db')
|
| 217 |
cursor = conn.cursor()
|
| 218 |
-
cursor.execute('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
conn.commit()
|
| 220 |
conn.close()
|
| 221 |
|
| 222 |
-
return f"Contact added: {name} - {phone} - {email}", 200
|
| 223 |
except Exception as e:
|
| 224 |
-
print(f"Error adding contact: {e}")
|
| 225 |
return "Internal Server Error", 500
|
| 226 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
@app.route('/data_gc')
|
| 228 |
def show_data_gc():
|
| 229 |
try:
|
|
|
|
| 156 |
name = request.args.get('name')
|
| 157 |
phone = request.args.get('phone')
|
| 158 |
email = request.args.get('email')
|
| 159 |
+
vk_id = request.args.get('vk_id', '')
|
| 160 |
+
chat_id = request.args.get('chat_id', '')
|
| 161 |
+
ws_statys = request.args.get('ws_statys', '')
|
| 162 |
+
ws_stop = request.args.get('ws_stop', '')
|
| 163 |
+
web_statys = request.args.get('web_statys', 0, type=int)
|
| 164 |
+
fin_progress = request.args.get('fin_progress', 0, type=int)
|
| 165 |
+
shop_statys_full = request.args.get('shop_statys_full', '')
|
| 166 |
+
pr1 = request.args.get('pr1', '')
|
| 167 |
+
pr2 = request.args.get('pr2', '')
|
| 168 |
+
pr3 = request.args.get('pr3', '')
|
| 169 |
+
pr4 = request.args.get('pr4', '')
|
| 170 |
+
pr5 = request.args.get('pr5', '')
|
| 171 |
+
ad_url = request.args.get('ad_url', '')
|
| 172 |
|
| 173 |
if not name or not phone or not email:
|
| 174 |
return "Parameters 'name', 'phone', and 'email' are required.", 400
|
| 175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
conn = sqlite3.connect('data_gc.db')
|
| 177 |
cursor = conn.cursor()
|
| 178 |
cursor.execute('SELECT * FROM contacts WHERE phone = ? OR email = ?', (phone, email))
|
| 179 |
existing_contact = cursor.fetchone()
|
| 180 |
|
| 181 |
if existing_contact:
|
| 182 |
+
cursor.execute('''
|
| 183 |
+
UPDATE contacts SET
|
| 184 |
+
name = ?, email = ?, vk_id = ?, chat_id = ?, ws_statys = ?, ws_stop = ?,
|
| 185 |
+
web_statys = ?, fin_progress = ?, shop_statys_full = ?, pr1 = ?, pr2 = ?,
|
| 186 |
+
pr3 = ?, pr4 = ?, pr5 = ?, ad_url = ?
|
| 187 |
+
WHERE phone = ? OR email = ?
|
| 188 |
+
''', (name, email, vk_id, chat_id, ws_statys, ws_stop, web_statys, fin_progress,
|
| 189 |
+
shop_statys_full, pr1, pr2, pr3, pr4, pr5, ad_url, phone, email))
|
| 190 |
+
else:
|
| 191 |
+
cursor.execute('''
|
| 192 |
+
INSERT INTO contacts (
|
| 193 |
+
name, phone, email, vk_id, chat_id, ws_statys, ws_stop, web_statys, fin_progress,
|
| 194 |
+
shop_statys_full, pr1, pr2, pr3, pr4, pr5, ad_url
|
| 195 |
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
| 196 |
+
''', (name, phone, email, vk_id, chat_id, ws_statys, ws_stop, web_statys, fin_progress,
|
| 197 |
+
shop_statys_full, pr1, pr2, pr3, pr4, pr5, ad_url))
|
| 198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
conn.commit()
|
| 200 |
conn.close()
|
| 201 |
|
| 202 |
+
return f"Contact updated/added: {name} - {phone} - {email}", 200
|
| 203 |
except Exception as e:
|
| 204 |
+
print(f"Error adding/updating contact: {e}")
|
| 205 |
return "Internal Server Error", 500
|
|
|
|
|
|
|
| 206 |
|
| 207 |
|
| 208 |
|
|
|
|
| 212 |
name = request.args.get('name')
|
| 213 |
phone = request.args.get('phone')
|
| 214 |
email = request.args.get('email')
|
| 215 |
+
vk_id = request.args.get('vk_id', '')
|
| 216 |
+
chat_id = request.args.get('chat_id', '')
|
| 217 |
+
ws_statys = request.args.get('ws_statys', '')
|
| 218 |
+
ws_stop = request.args.get('ws_stop', '')
|
| 219 |
+
web_statys = request.args.get('web_statys', 0, type=int)
|
| 220 |
+
fin_progress = request.args.get('fin_progress', 0, type=int)
|
| 221 |
+
shop_statys_full = request.args.get('shop_statys_full', '')
|
| 222 |
+
pr1 = request.args.get('pr1', '')
|
| 223 |
+
pr2 = request.args.get('pr2', '')
|
| 224 |
+
pr3 = request.args.get('pr3', '')
|
| 225 |
+
pr4 = request.args.get('pr4', '')
|
| 226 |
+
pr5 = request.args.get('pr5', '')
|
| 227 |
+
ad_url = request.args.get('ad_url', '')
|
| 228 |
|
| 229 |
if not name or not phone or not email:
|
| 230 |
return "Parameters 'name', 'phone', and 'email' are required.", 400
|
| 231 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
conn = sqlite3.connect('data1.db')
|
| 233 |
cursor = conn.cursor()
|
| 234 |
+
cursor.execute('SELECT * FROM contacts WHERE phone = ? OR email = ?', (phone, email))
|
| 235 |
+
existing_contact = cursor.fetchone()
|
| 236 |
+
|
| 237 |
+
if existing_contact:
|
| 238 |
+
cursor.execute('''
|
| 239 |
+
UPDATE contacts SET
|
| 240 |
+
name = ?, email = ?, vk_id = ?, chat_id = ?, ws_statys = ?, ws_stop = ?,
|
| 241 |
+
web_statys = ?, fin_progress = ?, shop_statys_full = ?, pr1 = ?, pr2 = ?,
|
| 242 |
+
pr3 = ?, pr4 = ?, pr5 = ?, ad_url = ?
|
| 243 |
+
WHERE phone = ? OR email = ?
|
| 244 |
+
''', (name, email, vk_id, chat_id, ws_statys, ws_stop, web_statys, fin_progress,
|
| 245 |
+
shop_statys_full, pr1, pr2, pr3, pr4, pr5, ad_url, phone, email))
|
| 246 |
+
else:
|
| 247 |
+
cursor.execute('''
|
| 248 |
+
INSERT INTO contacts (
|
| 249 |
+
name, phone, email, vk_id, chat_id, ws_statys, ws_stop, web_statys, fin_progress,
|
| 250 |
+
shop_statys_full, pr1, pr2, pr3, pr4, pr5, ad_url
|
| 251 |
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
| 252 |
+
''', (name, phone, email, vk_id, chat_id, ws_statys, ws_stop, web_statys, fin_progress,
|
| 253 |
+
shop_statys_full, pr1, pr2, pr3, pr4, pr5, ad_url))
|
| 254 |
+
|
| 255 |
conn.commit()
|
| 256 |
conn.close()
|
| 257 |
|
| 258 |
+
return f"Contact updated/added: {name} - {phone} - {email}", 200
|
| 259 |
except Exception as e:
|
| 260 |
+
print(f"Error adding/updating contact: {e}")
|
| 261 |
return "Internal Server Error", 500
|
| 262 |
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
|
| 271 |
@app.route('/data_gc')
|
| 272 |
def show_data_gc():
|
| 273 |
try:
|