DmitrMakeev commited on
Commit
0beecc1
·
verified ·
1 Parent(s): cae6611

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -31
app.py CHANGED
@@ -64,13 +64,15 @@ app = Flask(__name__, template_folder="./")
64
  app.config['DEBUG'] = True
65
 
66
  UPLOAD_FOLDER = 'static'
 
67
 
68
 
69
- # Создание директории, если она не существует
70
  if not os.path.exists(UPLOAD_FOLDER):
71
  os.makedirs(UPLOAD_FOLDER)
72
 
73
 
 
 
74
  DATABASES = ['data_gc.db', 'data1.db', 'data2.db', 'data3.db', 'data4.db', 'data5.db']
75
 
76
 
@@ -1138,33 +1140,6 @@ def online():
1138
 
1139
 
1140
 
1141
- @app.route('/upload', methods=['POST'])
1142
- def upload_file():
1143
- if 'file' not in request.files:
1144
- return "No file part", 400
1145
- file = request.files['file']
1146
- if file.filename == '':
1147
- return "No selected file", 400
1148
-
1149
- # Генерация уникального имени файла
1150
- unique_filename = str(uuid.uuid4()) + os.path.splitext(file.filename)[1]
1151
- save_path = os.path.join(UPLOAD_FOLDER, unique_filename)
1152
- file.save(save_path)
1153
-
1154
- # Возвращаем полный URL загруженного файла с протоколом https
1155
- full_url = request.url_root.replace('http://', 'https://') + 'uploads/' + unique_filename
1156
- return f"File uploaded successfully and saved to {full_url}", 200
1157
-
1158
- @app.route('/uploads/<filename>', methods=['GET'])
1159
- def uploaded_file(filename):
1160
- return send_from_directory(UPLOAD_FOLDER, filename)
1161
-
1162
- @app.route('/up_fa', methods=['GET'])
1163
- def up_fa():
1164
- return render_template('up_fa.html')
1165
-
1166
-
1167
-
1168
 
1169
 
1170
 
@@ -1261,7 +1236,7 @@ def buil_json_gen():
1261
 
1262
 
1263
  @app.route('/up_page', methods=['POST'])
1264
- def upload2_file():
1265
  if 'file' not in request.files or 'filename' not in request.form:
1266
  return "No file or filename provided", 400
1267
  file = request.files['file']
@@ -1286,13 +1261,13 @@ def upload2_file():
1286
  return f"File uploaded successfully and saved to {full_url}", 200
1287
 
1288
  @app.route('/page/<filename>', methods=['GET'])
1289
- def uploaded2_file(filename):
1290
  # Добавляем расширение .html к имени файла
1291
  filename_with_extension = filename + '.html'
1292
  return send_from_directory(UPLOAD_FOLDER, filename_with_extension)
1293
 
1294
  @app.route('/pages', methods=['GET'])
1295
- def up2_pages():
1296
  return render_template('pages.html')
1297
 
1298
 
 
64
  app.config['DEBUG'] = True
65
 
66
  UPLOAD_FOLDER = 'static'
67
+ logging.basicConfig(level=logging.DEBUG)
68
 
69
 
 
70
  if not os.path.exists(UPLOAD_FOLDER):
71
  os.makedirs(UPLOAD_FOLDER)
72
 
73
 
74
+
75
+
76
  DATABASES = ['data_gc.db', 'data1.db', 'data2.db', 'data3.db', 'data4.db', 'data5.db']
77
 
78
 
 
1140
 
1141
 
1142
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1143
 
1144
 
1145
 
 
1236
 
1237
 
1238
  @app.route('/up_page', methods=['POST'])
1239
+ def upload_file():
1240
  if 'file' not in request.files or 'filename' not in request.form:
1241
  return "No file or filename provided", 400
1242
  file = request.files['file']
 
1261
  return f"File uploaded successfully and saved to {full_url}", 200
1262
 
1263
  @app.route('/page/<filename>', methods=['GET'])
1264
+ def uploaded_file(filename):
1265
  # Добавляем расширение .html к имени файла
1266
  filename_with_extension = filename + '.html'
1267
  return send_from_directory(UPLOAD_FOLDER, filename_with_extension)
1268
 
1269
  @app.route('/pages', methods=['GET'])
1270
+ def up_pages():
1271
  return render_template('pages.html')
1272
 
1273