Update app.py
Browse files
app.py
CHANGED
@@ -1849,10 +1849,61 @@ def registrations_period():
|
|
1849 |
# Маршрут для отображения страницы с графиком за период
|
1850 |
@app.route('/show_registrations_period', methods=['GET'])
|
1851 |
def show_registrations_period():
|
|
|
|
|
|
|
|
|
|
|
|
|
1852 |
return render_template('registrations_period.html')
|
1853 |
|
1854 |
|
1855 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1856 |
|
1857 |
|
1858 |
|
|
|
1849 |
# Маршрут для отображения страницы с графиком за период
|
1850 |
@app.route('/show_registrations_period', methods=['GET'])
|
1851 |
def show_registrations_period():
|
1852 |
+
api_sys_control = request.args.get('api_sys')
|
1853 |
+
|
1854 |
+
# Проверяем значение параметра `api_sys_control`
|
1855 |
+
if api_sys_control != 'your_api_key_here': # Замените `your_api_key_here` на ваш ключ
|
1856 |
+
return jsonify({'error': 'Access denied: Invalid API key'}), 403
|
1857 |
+
|
1858 |
return render_template('registrations_period.html')
|
1859 |
|
1860 |
|
1861 |
|
1862 |
+
# Маршрут для удаления вообще
|
1863 |
+
def get_db_connection():
|
1864 |
+
conn = sqlite3.connect('database.db')
|
1865 |
+
conn.row_factory = sqlite3.Row
|
1866 |
+
return conn
|
1867 |
+
|
1868 |
+
@app.route('/delete_user', methods=['GET'])
|
1869 |
+
def delete_user():
|
1870 |
+
api_sys_control = request.args.get('api_sys')
|
1871 |
+
|
1872 |
+
# Проверяем значение параметра `api_sys_control`
|
1873 |
+
if api_sys_control != 'your_api_key_here': # Замените `your_api_key_here` на ваш ключ
|
1874 |
+
return jsonify({'error': 'Access denied: Invalid API key'}), 403
|
1875 |
+
|
1876 |
+
email = request.args.get('email')
|
1877 |
+
|
1878 |
+
# Проверяем, что email был передан
|
1879 |
+
if not email:
|
1880 |
+
return jsonify({'error': 'Email is required'}), 400
|
1881 |
+
|
1882 |
+
# Проверяем и удаляем записи в базе
|
1883 |
+
try:
|
1884 |
+
with sqlite3.connect('your_database_name.db') as conn: # Замените имя базы данных
|
1885 |
+
cursor = conn.cursor()
|
1886 |
+
cursor.execute("SELECT COUNT(*) FROM users WHERE email = ?", (email,))
|
1887 |
+
count = cursor.fetchone()[0]
|
1888 |
+
|
1889 |
+
if count == 0:
|
1890 |
+
return jsonify({'message': 'No records found for the provided email'}), 404
|
1891 |
+
|
1892 |
+
cursor.execute("DELETE FROM users WHERE email = ?", (email,))
|
1893 |
+
conn.commit()
|
1894 |
+
|
1895 |
+
return jsonify({'message': f'{count} records deleted for email: {email}'}), 200
|
1896 |
+
|
1897 |
+
except sqlite3.Error as e:
|
1898 |
+
return jsonify({'error': f'Database error: {str(e)}'}), 500
|
1899 |
+
|
1900 |
+
|
1901 |
+
|
1902 |
+
|
1903 |
+
|
1904 |
+
|
1905 |
+
|
1906 |
+
|
1907 |
|
1908 |
|
1909 |
|