|
6 | 6 | app = Flask(__name__)
|
7 | 7 | app.config["UPLOAD_FOLDER"] = "/mnt/ofc.wlpizza_storage"
|
8 | 8 | app.config['MAX_CONTENT_LENGTH'] = 100 * 1024 * 1024 # Max 100 MB.
|
9 |
| -ALLOWED_EXTENSIONS = [ |
10 |
| - 'js', 'css', 'html', 'json', 'txt', 'mp4', 'avi', 'flv', 'mov', 'wmv', |
11 |
| - 'png', 'jpg', 'jpeg', 'gif', 'tiff', 'bmp', 'mp3', 'wav', 'flac', 'aac', |
12 |
| - 'ogg', 'alac', 'zip', '7z', 'rar', 'pdf', 'exe'] |
13 | 9 |
|
14 | 10 |
|
15 | 11 | @app.route('/', methods=['GET', 'POST'])
|
16 | 12 | def index():
|
17 |
| - return render_template('index.html', allowed_ext=", ".join(ALLOWED_EXTENSIONS)) |
| 13 | + return render_template('index.html') |
18 | 14 |
|
19 | 15 |
|
20 | 16 | @app.route('/upload', methods=['POST'])
|
21 | 17 | def upload():
|
22 | 18 | fileob = request.files["file"]
|
23 | 19 | fext = secure_filename(fileob.filename).split('.')[-1].lower()
|
24 |
| - if fext.lower() not in ALLOWED_EXTENSIONS: |
25 |
| - return "Error: Filename extension not allowed." |
26 | 20 | filename = "{}.{}".format(''.join(sample(string.ascii_letters + string.digits, 6)), fext)
|
27 | 21 | save_path = "{}/{}".format(app.config["UPLOAD_FOLDER"], filename)
|
28 | 22 | fileob.save(save_path)
|
29 |
| - return '/files/' + filename |
| 23 | + return request.url_root + 'files/' + filename |
0 commit comments