Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from flask import Flask, request, render_template_string
|
| 2 |
import requests
|
| 3 |
import os
|
| 4 |
import pytz
|
|
@@ -733,37 +733,7 @@ def save_db():
|
|
| 733 |
|
| 734 |
|
| 735 |
|
| 736 |
-
@app.route('/conta')
|
| 737 |
-
def get_contacts_json():
|
| 738 |
-
try:
|
| 739 |
-
conn = sqlite3.connect('data.db')
|
| 740 |
-
cursor = conn.cursor()
|
| 741 |
-
cursor.execute('SELECT name, email, phone, pr1, pr2, pr3, pr4, pr5, date, time FROM contacts')
|
| 742 |
-
contacts = cursor.fetchall()
|
| 743 |
-
conn.close()
|
| 744 |
|
| 745 |
-
# Prepare JSON response
|
| 746 |
-
contacts_json = []
|
| 747 |
-
for contact in contacts:
|
| 748 |
-
contact_dict = {
|
| 749 |
-
'name': contact[0],
|
| 750 |
-
'email': contact[1],
|
| 751 |
-
'phone': contact[2],
|
| 752 |
-
'pr1': contact[3],
|
| 753 |
-
'pr2': contact[4],
|
| 754 |
-
'pr3': contact[5],
|
| 755 |
-
'pr4': contact[6],
|
| 756 |
-
'pr5': contact[7],
|
| 757 |
-
'date': contact[8],
|
| 758 |
-
'time': contact[9]
|
| 759 |
-
}
|
| 760 |
-
contacts_json.append(contact_dict)
|
| 761 |
-
|
| 762 |
-
return jsonify(contacts_json), 200 # Return JSON response with contacts data
|
| 763 |
-
|
| 764 |
-
except Exception as e:
|
| 765 |
-
print(f"Error getting contacts JSON: {e}")
|
| 766 |
-
return jsonify({'error': 'Database error. Please try again later.'}), 500
|
| 767 |
|
| 768 |
|
| 769 |
|
|
|
|
| 1 |
+
from flask import Flask, request, render_template_string, render_template
|
| 2 |
import requests
|
| 3 |
import os
|
| 4 |
import pytz
|
|
|
|
| 733 |
|
| 734 |
|
| 735 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 736 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 737 |
|
| 738 |
|
| 739 |
|