Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
771f557bae
|
|||
|
4c87869392
|
|||
|
2e5d1ce78a
|
|||
|
005a70ca65
|
|||
|
aea43550c4
|
|||
|
d301da7f09
|
|||
|
d5c38e322c
|
|||
|
46ba681137
|
|||
|
a2d50eccb0
|
|||
|
090676d82e
|
|||
|
6d598bde26
|
|||
|
69c8540e83
|
@@ -1,3 +1,7 @@
|
|||||||
|
# Navidrome Upload Utility
|
||||||
|
# Arian Nasr
|
||||||
|
# March 6, 2026
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from flask import Flask, request, render_template
|
from flask import Flask, request, render_template
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
@@ -12,24 +16,23 @@ def allowed_file(filename):
|
|||||||
return '.' in filename and \
|
return '.' in filename and \
|
||||||
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
||||||
|
|
||||||
|
@app.route('/ping')
|
||||||
|
def ping():
|
||||||
|
return 'pong', 200
|
||||||
|
|
||||||
@app.route('/', methods=['GET', 'POST'])
|
@app.route('/', methods=['GET', 'POST'])
|
||||||
def upload_file():
|
def upload_file():
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
if 'file' not in request.files:
|
for key, file in request.files.items():
|
||||||
return render_template('error.html', error_message='No file part in the request'), 400
|
if key.startswith('file') and file and allowed_file(file.filename) and file.filename != '':
|
||||||
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):
|
|
||||||
filename = secure_filename(file.filename)
|
filename = secure_filename(file.filename)
|
||||||
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
|
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
|
||||||
else:
|
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__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Vendored
+1
File diff suppressed because one or more lines are too long
@@ -1,4 +1,10 @@
|
|||||||
body {
|
body {
|
||||||
background-color: #2B2726;
|
background-color: #252526;
|
||||||
color: #FFFFFF;
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
.dropzone {
|
||||||
|
background: #3e3e42 !important;
|
||||||
|
border-radius: 2rem !important;
|
||||||
|
border-style: dashed !important;
|
||||||
|
border-color: #FFFFFF !important;
|
||||||
}
|
}
|
||||||
Vendored
+1
File diff suppressed because one or more lines are too long
+12
-5
@@ -5,12 +5,19 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Upload Music</title>
|
<title>Upload Music</title>
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}" type="text/css" />
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}" type="text/css" />
|
||||||
|
<script src="{{ url_for('static', filename='js/dropzone.min.js') }}"></script>
|
||||||
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/dropzone.min.css') }}" type="text/css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Upload new File</h1>
|
<script>
|
||||||
<form method=post enctype=multipart/form-data>
|
Dropzone.options.myDropzone = {
|
||||||
<input type=file name=file multiple>
|
parallelUploads: 2,
|
||||||
<input type=submit value=Upload>
|
uploadMultiple: true,
|
||||||
</form>
|
acceptedFiles: 'audio/*'
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<form action="/"
|
||||||
|
class="dropzone"
|
||||||
|
id="my-dropzone"></form>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user