Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -378,8 +378,8 @@ def save_db():
|
|
| 378 |
else:
|
| 379 |
return response.text
|
| 380 |
|
| 381 |
-
@app.route('/
|
| 382 |
-
def
|
| 383 |
try:
|
| 384 |
conn = sqlite3.connect('data1.db')
|
| 385 |
cursor = conn.cursor()
|
|
@@ -387,7 +387,7 @@ def show_contacts():
|
|
| 387 |
contacts = cursor.fetchall()
|
| 388 |
conn.close()
|
| 389 |
|
| 390 |
-
return render_template('
|
| 391 |
|
| 392 |
except sqlite3.Error as e:
|
| 393 |
print(f"SQLite error: {e}")
|
|
@@ -397,5 +397,56 @@ def show_contacts():
|
|
| 397 |
print(f"Error showing contacts: {e}")
|
| 398 |
return "Internal Server Error", 500
|
| 399 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 400 |
if __name__ == '__main__':
|
| 401 |
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860)))
|
|
|
|
| 378 |
else:
|
| 379 |
return response.text
|
| 380 |
|
| 381 |
+
@app.route('/contacts1')
|
| 382 |
+
def show_contacts1():
|
| 383 |
try:
|
| 384 |
conn = sqlite3.connect('data1.db')
|
| 385 |
cursor = conn.cursor()
|
|
|
|
| 387 |
contacts = cursor.fetchall()
|
| 388 |
conn.close()
|
| 389 |
|
| 390 |
+
return render_template('contacts1.html', contacts=contacts), 200
|
| 391 |
|
| 392 |
except sqlite3.Error as e:
|
| 393 |
print(f"SQLite error: {e}")
|
|
|
|
| 397 |
print(f"Error showing contacts: {e}")
|
| 398 |
return "Internal Server Error", 500
|
| 399 |
|
| 400 |
+
|
| 401 |
+
|
| 402 |
+
@app.route('/contacts2')
|
| 403 |
+
def show_contacts2():
|
| 404 |
+
try:
|
| 405 |
+
conn = sqlite3.connect('data2.db')
|
| 406 |
+
cursor = conn.cursor()
|
| 407 |
+
cursor.execute('SELECT name, email, phone, pr1, pr2, pr3, pr4, pr5, date, time FROM contacts')
|
| 408 |
+
contacts = cursor.fetchall()
|
| 409 |
+
conn.close()
|
| 410 |
+
|
| 411 |
+
return render_template('contacts2.html', contacts=contacts), 200
|
| 412 |
+
|
| 413 |
+
except sqlite3.Error as e:
|
| 414 |
+
print(f"SQLite error: {e}")
|
| 415 |
+
return "Database error. Please try again later.", 500
|
| 416 |
+
|
| 417 |
+
except Exception as e:
|
| 418 |
+
print(f"Error showing contacts: {e}")
|
| 419 |
+
return "Internal Server Error", 500
|
| 420 |
+
|
| 421 |
+
|
| 422 |
+
|
| 423 |
+
|
| 424 |
+
|
| 425 |
+
@app.route('/contacts3')
|
| 426 |
+
def show_contacts3():
|
| 427 |
+
try:
|
| 428 |
+
conn = sqlite3.connect('data3.db')
|
| 429 |
+
cursor = conn.cursor()
|
| 430 |
+
cursor.execute('SELECT name, email, phone, pr1, pr2, pr3, pr4, pr5, date, time FROM contacts')
|
| 431 |
+
contacts = cursor.fetchall()
|
| 432 |
+
conn.close()
|
| 433 |
+
|
| 434 |
+
return render_template('contacts3.html', contacts=contacts), 200
|
| 435 |
+
|
| 436 |
+
except sqlite3.Error as e:
|
| 437 |
+
print(f"SQLite error: {e}")
|
| 438 |
+
return "Database error. Please try again later.", 500
|
| 439 |
+
|
| 440 |
+
except Exception as e:
|
| 441 |
+
print(f"Error showing contacts: {e}")
|
| 442 |
+
return "Internal Server Error", 500
|
| 443 |
+
|
| 444 |
+
|
| 445 |
+
|
| 446 |
+
|
| 447 |
+
|
| 448 |
+
|
| 449 |
+
|
| 450 |
+
|
| 451 |
if __name__ == '__main__':
|
| 452 |
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860)))
|