Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
771f557bae
|
|||
|
4c87869392
|
|||
|
2e5d1ce78a
|
|||
|
005a70ca65
|
|||
|
aea43550c4
|
|||
|
d301da7f09
|
|||
|
d5c38e322c
|
|||
|
46ba681137
|
|||
|
a2d50eccb0
|
@@ -2,7 +2,6 @@
|
||||
# Arian Nasr
|
||||
# March 6, 2026
|
||||
|
||||
|
||||
import os
|
||||
from flask import Flask, request, render_template
|
||||
from werkzeug.utils import secure_filename
|
||||
@@ -17,24 +16,23 @@ def allowed_file(filename):
|
||||
return '.' in filename and \
|
||||
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
||||
|
||||
@app.route('/ping')
|
||||
def ping():
|
||||
return 'pong', 200
|
||||
|
||||
@app.route('/', methods=['GET', 'POST'])
|
||||
def upload_file():
|
||||
if request.method == 'POST':
|
||||
if 'file' not in request.files:
|
||||
return render_template('error.html', error_message='No file part in the request'), 400
|
||||
files = request.files.getlist('file')
|
||||
for file in files:
|
||||
if file.filename == '':
|
||||
return render_template('error.html', error_message='No selected file'), 400
|
||||
if file and allowed_file(file.filename):
|
||||
for key, file in request.files.items():
|
||||
if key.startswith('file') and file and allowed_file(file.filename) and file.filename != '':
|
||||
filename = secure_filename(file.filename)
|
||||
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
|
||||
else:
|
||||
return render_template('error.html', error_message=f'File "{file.filename}" is not allowed. Allowed types: {", ".join(ALLOWED_EXTENSIONS)}'), 400
|
||||
return render_template('error.html', error_message=f'File is not allowed.'), 400
|
||||
|
||||
return render_template('success.html', success_message=f'{len(files)} file(s) uploaded successfully!')
|
||||
return render_template('success.html', success_message=f'{len(request.files)} file(s) uploaded successfully!'), 200
|
||||
|
||||
return render_template('index.html')
|
||||
return render_template('index.html'), 200
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
body {
|
||||
background-color: #2B2726;
|
||||
background-color: #252526;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
.dropzone {
|
||||
background: #3e3e42 !important;
|
||||
border-radius: 2rem !important;
|
||||
border-style: dashed !important;
|
||||
border-color: #FFFFFF !important;
|
||||
}
|
||||
@@ -9,7 +9,6 @@
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/dropzone.min.css') }}" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Drag & drop files here or <b>browse</b></h1>
|
||||
<script>
|
||||
Dropzone.options.myDropzone = {
|
||||
parallelUploads: 2,
|
||||
|
||||
Reference in New Issue
Block a user