forked from nadvista/Team1_PPE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.py
24 lines (20 loc) · 870 Bytes
/
upload.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from flask import Blueprint, request, redirect, url_for, render_template,current_app
from werkzeug.utils import secure_filename
upload_bp = Blueprint('upload', __name__,
template_folder='templates')
@upload_bp.route('/', methods=['POST'])
def upload_file_POST():
# Сохраняет файл
if 'file' not in request.files:
return redirect(request.url)
file = request.files['file']
if file.filename == '':
return redirect(request.url)
filename = "tempfile.mp4"
filepath = f"{current_app.config['UPLOAD_FOLDER']}/{filename}"
file.save(filepath)
###########################################################################
return redirect(url_for('loading.loading',file=filename))
@upload_bp.route('/', methods=['GET'])
def upload_file_GET():
return render_template('index.html')