Update app.py
Browse files
app.py
CHANGED
|
@@ -87,17 +87,6 @@ def se_mes_im():
|
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
|
| 102 |
|
| 103 |
|
|
@@ -107,9 +96,9 @@ def online():
|
|
| 107 |
|
| 108 |
@app.route('/upload', methods=['POST'])
|
| 109 |
def upload_file():
|
| 110 |
-
if '
|
| 111 |
return "No file part", 400
|
| 112 |
-
file = request.files['
|
| 113 |
if file.filename == '':
|
| 114 |
return "No selected file", 400
|
| 115 |
|
|
@@ -119,9 +108,17 @@ def upload_file():
|
|
| 119 |
file.save(save_path)
|
| 120 |
|
| 121 |
# Возвращаем полный URL загруженного файла с протоколом https
|
| 122 |
-
full_url = request.url_root.replace('http://', 'https://') + '
|
| 123 |
return f"File uploaded successfully and saved to {full_url}", 200
|
| 124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
@app.route('/image/<filename>', methods=['GET'])
|
| 126 |
def get_image(filename):
|
| 127 |
return send_from_directory(UPLOAD_FOLDER, filename)
|
|
|
|
| 87 |
|
| 88 |
|
| 89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
|
| 92 |
|
|
|
|
| 96 |
|
| 97 |
@app.route('/upload', methods=['POST'])
|
| 98 |
def upload_file():
|
| 99 |
+
if 'file' not in request.files: # Изменено на 'file'
|
| 100 |
return "No file part", 400
|
| 101 |
+
file = request.files['file']
|
| 102 |
if file.filename == '':
|
| 103 |
return "No selected file", 400
|
| 104 |
|
|
|
|
| 108 |
file.save(save_path)
|
| 109 |
|
| 110 |
# Возвращаем полный URL загруженного файла с протоколом https
|
| 111 |
+
full_url = request.url_root.replace('http://', 'https://') + 'uploads/' + unique_filename
|
| 112 |
return f"File uploaded successfully and saved to {full_url}", 200
|
| 113 |
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
|
| 122 |
@app.route('/image/<filename>', methods=['GET'])
|
| 123 |
def get_image(filename):
|
| 124 |
return send_from_directory(UPLOAD_FOLDER, filename)
|