DmitrMakeev commited on
Commit
0e8b5e0
·
verified ·
1 Parent(s): 249c69e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -0
app.py CHANGED
@@ -2209,7 +2209,46 @@ def serve_html(filename):
2209
  def up_page():
2210
  return render_template('up_page.html')
2211
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2212
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2213
 
2214
 
2215
 
@@ -2218,6 +2257,8 @@ def up_page():
2218
 
2219
 
2220
 
 
 
2221
  @app.route('/monitor', methods=['GET'])
2222
  def monitor():
2223
  # Получаем информацию о загруженных файлах
 
2209
  def up_page():
2210
  return render_template('up_page.html')
2211
 
2212
+ # Дублированный маршрут для загрузки страницы через POST-запрос
2213
+ @app.route('/up_page_vk', methods=['POST'])
2214
+ def upload_page_vk():
2215
+ # Получаем ключ авторизации из запроса
2216
+ api_sys_control = request.form.get('api_key_sys')
2217
+
2218
+ # Проверка ключа авторизации
2219
+ if api_sys_control != api_key_sys:
2220
+ return jsonify({"error": "Unauthorized access"}), 403
2221
+
2222
+ if 'file' not in request.files:
2223
+ return jsonify({"error": "No file part"}), 400
2224
+
2225
+ file = request.files['file']
2226
+
2227
+ if file.filename == '':
2228
+ return jsonify({"error": "No selected file"}), 400
2229
 
2230
+ filename = request.form.get('filename')
2231
+ if not filename:
2232
+ return jsonify({"error": "Filename is required"}), 400
2233
+
2234
+ save_path = os.path.join(HTML_FOLDER_VK, filename + '.html')
2235
+ file.save(save_path)
2236
+
2237
+ # Возвращаем полный URL загруженного файла с протоколом https
2238
+ full_url = request.url_root.replace('http://', 'https://') + 'page_vk/' + filename
2239
+ return jsonify({"message": "Page uploaded successfully", "url": full_url}), 200
2240
+
2241
+ # Дублированный маршрут для отображения страницы загрузки
2242
+ @app.route('/up_page_vk', methods=['GET'])
2243
+ def up_page_vk():
2244
+ return render_template('up_page_vk.html')
2245
+
2246
+ # Дублированный маршрут для обслуживания загруженных страниц
2247
+ @app.route('/page_vk/<path:filename>', methods=['GET'])
2248
+ def serve_html_vk(filename):
2249
+ if not filename.endswith('.html'):
2250
+ filename += '.html'
2251
+ return send_from_directory(HTML_FOLDER_VK, filename)
2252
 
2253
 
2254
 
 
2257
 
2258
 
2259
 
2260
+
2261
+
2262
  @app.route('/monitor', methods=['GET'])
2263
  def monitor():
2264
  # Получаем информацию о загруженных файлах