Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1885,30 +1885,34 @@ def get_group_parameters(group_id):
|
|
| 1885 |
|
| 1886 |
|
| 1887 |
|
| 1888 |
-
|
| 1889 |
-
|
| 1890 |
-
|
| 1891 |
-
|
| 1892 |
-
|
| 1893 |
|
| 1894 |
@app.route('/up_page', methods=['POST'])
|
| 1895 |
def upload_page():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1896 |
if 'file' not in request.files:
|
| 1897 |
-
return "No file part", 400
|
|
|
|
| 1898 |
file = request.files['file']
|
|
|
|
| 1899 |
if file.filename == '':
|
| 1900 |
-
return "No selected file", 400
|
| 1901 |
-
|
| 1902 |
filename = request.form.get('filename')
|
| 1903 |
if not filename:
|
| 1904 |
-
return "Filename is required", 400
|
| 1905 |
-
|
| 1906 |
save_path = os.path.join(HTML_FOLDER, filename + '.html')
|
| 1907 |
file.save(save_path)
|
| 1908 |
-
|
| 1909 |
# Возвращаем полный URL загруженного файла с протоколом https
|
| 1910 |
full_url = request.url_root.replace('http://', 'https://') + filename
|
| 1911 |
-
return
|
| 1912 |
|
| 1913 |
@app.route('/<path:filename>', methods=['GET'])
|
| 1914 |
def serve_html(filename):
|
|
@@ -1920,6 +1924,15 @@ def serve_html(filename):
|
|
| 1920 |
def up_page():
|
| 1921 |
return render_template('up_page.html')
|
| 1922 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1923 |
@app.route('/monitor', methods=['GET'])
|
| 1924 |
def monitor():
|
| 1925 |
# Получаем информацию о загруженных файлах
|
|
|
|
| 1885 |
|
| 1886 |
|
| 1887 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1888 |
|
| 1889 |
@app.route('/up_page', methods=['POST'])
|
| 1890 |
def upload_page():
|
| 1891 |
+
# Получаем ключ авторизации из запроса
|
| 1892 |
+
api_sys_control = request.form.get('api_key_sys')
|
| 1893 |
+
|
| 1894 |
+
# Проверка ключа авторизации
|
| 1895 |
+
if api_sys_control != api_key_sys:
|
| 1896 |
+
return jsonify({"error": "Unauthorized access"}), 403
|
| 1897 |
+
|
| 1898 |
if 'file' not in request.files:
|
| 1899 |
+
return jsonify({"error": "No file part"}), 400
|
| 1900 |
+
|
| 1901 |
file = request.files['file']
|
| 1902 |
+
|
| 1903 |
if file.filename == '':
|
| 1904 |
+
return jsonify({"error": "No selected file"}), 400
|
| 1905 |
+
|
| 1906 |
filename = request.form.get('filename')
|
| 1907 |
if not filename:
|
| 1908 |
+
return jsonify({"error": "Filename is required"}), 400
|
| 1909 |
+
|
| 1910 |
save_path = os.path.join(HTML_FOLDER, filename + '.html')
|
| 1911 |
file.save(save_path)
|
| 1912 |
+
|
| 1913 |
# Возвращаем полный URL загруженного файла с протоколом https
|
| 1914 |
full_url = request.url_root.replace('http://', 'https://') + filename
|
| 1915 |
+
return jsonify({"message": "Page uploaded successfully", "url": full_url}), 200
|
| 1916 |
|
| 1917 |
@app.route('/<path:filename>', methods=['GET'])
|
| 1918 |
def serve_html(filename):
|
|
|
|
| 1924 |
def up_page():
|
| 1925 |
return render_template('up_page.html')
|
| 1926 |
|
| 1927 |
+
|
| 1928 |
+
|
| 1929 |
+
|
| 1930 |
+
|
| 1931 |
+
|
| 1932 |
+
|
| 1933 |
+
|
| 1934 |
+
|
| 1935 |
+
|
| 1936 |
@app.route('/monitor', methods=['GET'])
|
| 1937 |
def monitor():
|
| 1938 |
# Получаем информацию о загруженных файлах
|