Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -104,41 +104,6 @@ def handle_incoming_request():
|
|
104 |
# Возвращаем список ответов
|
105 |
return {'responses': [response_1]}
|
106 |
|
107 |
-
@app.route('/contacts')
|
108 |
-
def show_contacts():
|
109 |
-
return render_template('contacts.html')
|
110 |
-
|
111 |
-
@app.route('/api/contacts')
|
112 |
-
def get_contacts_json():
|
113 |
-
try:
|
114 |
-
conn = sqlite3.connect('data.db')
|
115 |
-
cursor = conn.cursor()
|
116 |
-
cursor.execute('SELECT name, email, phone, pr1, pr2, pr3, pr4, pr5, date, time FROM contacts')
|
117 |
-
contacts = cursor.fetchall()
|
118 |
-
conn.close()
|
119 |
-
|
120 |
-
# Prepare JSON response
|
121 |
-
contacts_json = []
|
122 |
-
for contact in contacts:
|
123 |
-
contact_dict = {
|
124 |
-
'name': contact[0],
|
125 |
-
'email': contact[1],
|
126 |
-
'phone': contact[2],
|
127 |
-
'pr1': contact[3],
|
128 |
-
'pr2': contact[4],
|
129 |
-
'pr3': contact[5],
|
130 |
-
'pr4': contact[6],
|
131 |
-
'pr5': contact[7],
|
132 |
-
'date': contact[8],
|
133 |
-
'time': contact[9]
|
134 |
-
}
|
135 |
-
contacts_json.append(contact_dict)
|
136 |
-
|
137 |
-
return jsonify(contacts_json), 200 # Return JSON response with contacts data
|
138 |
-
|
139 |
-
except Exception as e:
|
140 |
-
print(f"Error getting contacts JSON: {e}")
|
141 |
-
return jsonify({'error': 'Database error. Please try again later.'}), 500
|
142 |
|
143 |
|
144 |
elif current_day == 1: # Вторник
|
|
|
104 |
# Возвращаем список ответов
|
105 |
return {'responses': [response_1]}
|
106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
|
108 |
|
109 |
elif current_day == 1: # Вторник
|