Skip to content

Commit 0a5273d

Browse files
authored
Made Better TM
1 parent 0f2a8d6 commit 0a5273d

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

main.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,18 @@
66
app = Flask(__name__)
77
app.config["UPLOAD_FOLDER"] = "/mnt/ofc.wlpizza_storage"
88
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']
139

1410

1511
@app.route('/', methods=['GET', 'POST'])
1612
def index():
17-
return render_template('index.html', allowed_ext=", ".join(ALLOWED_EXTENSIONS))
13+
return render_template('index.html')
1814

1915

2016
@app.route('/upload', methods=['POST'])
2117
def upload():
2218
fileob = request.files["file"]
2319
fext = secure_filename(fileob.filename).split('.')[-1].lower()
24-
if fext.lower() not in ALLOWED_EXTENSIONS:
25-
return "Error: Filename extension not allowed."
2620
filename = "{}.{}".format(''.join(sample(string.ascii_letters + string.digits, 6)), fext)
2721
save_path = "{}/{}".format(app.config["UPLOAD_FOLDER"], filename)
2822
fileob.save(save_path)
29-
return '/files/' + filename
23+
return request.url_root + 'files/' + filename

0 commit comments

Comments
 (0)