3 Commits

Author SHA1 Message Date
arian a503d1e788 drag & drop functionality 2026-03-05 13:57:37 -05:00
arian fa0226e319 Revert "drag & drop functionality"
This reverts commit 1d582eec8f.
2026-03-05 13:52:16 -05:00
arian 1d582eec8f drag & drop functionality 2026-03-05 13:46:18 -05:00
7 changed files with 66 additions and 35 deletions
+10 -13
View File
@@ -1,7 +1,3 @@
# Navidrome Upload Utility
# Arian Nasr
# March 6, 2026
import os
from flask import Flask, request, render_template
from werkzeug.utils import secure_filename
@@ -16,23 +12,24 @@ 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':
for key, file in request.files.items():
if key.startswith('file') and file and allowed_file(file.filename) and file.filename != '':
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):
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 is not allowed.'), 400
return render_template('error.html', error_message=f'File "{file.filename}" is not allowed. Allowed types: {", ".join(ALLOWED_EXTENSIONS)}'), 400
return render_template('success.html', success_message=f'{len(request.files)} file(s) uploaded successfully!'), 200
return render_template('success.html', success_message=f'{len(files)} file(s) uploaded successfully!')
return render_template('index.html'), 200
return render_template('index.html')
if __name__ == '__main__':
-1
View File
File diff suppressed because one or more lines are too long
-10
View File
@@ -1,10 +0,0 @@
body {
background-color: #252526;
color: #FFFFFF;
}
.dropzone {
background: #3e3e42 !important;
border-radius: 2rem !important;
border-style: dashed !important;
border-color: #FFFFFF !important;
}
-1
View File
File diff suppressed because one or more lines are too long
+7 -1
View File
@@ -4,9 +4,15 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Error - Upload Music</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}" type="text/css" />
<style>
body {
background-color: #2B2726;
color: #FFFFFF;
}
</style>
</head>
<body>
<button onclick="window.location.href='/outpost.goauthentik.io/sign_out'">Logout</button>
<h1>Error</h1>
<p>{{ error_message }}</p>
<a href="/"><button>Upload another file</button></a>
+42 -8
View File
@@ -3,21 +3,55 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://s3.2ari.ca/navidrome-upload/dropzone.min.js"></script>
<link rel="stylesheet" href="https://s3.2ari.ca/navidrome-upload/dropzone.min.css" type="text/css" />
<title>Upload Music</title>
<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" />
<style>
body {
background-color: #2B2726;
color: #FFFFFF;
}
.dropzone {
border: 2px dashed #666;
border-radius: 5px;
background: #3B3736;
padding: 20px;
min-height: 200px;
}
.dropzone .dz-message {
color: #FFFFFF;
font-size: 18px;
}
</style>
</head>
<body>
<button onclick="window.location.href='/outpost.goauthentik.io/sign_out'">Logout</button>
<h1>Upload new File</h1>
<form action="/" method="post" enctype="multipart/form-data" class="dropzone" id="my-dropzone">
<div class="dz-message">
Drop files here or click to upload
</div>
</form>
<script>
Dropzone.options.myDropzone = {
parallelUploads: 2,
paramName: "file",
maxFilesize: 500, // MB
uploadMultiple: true,
acceptedFiles: 'audio/*'
parallelUploads: 5,
acceptedFiles: "audio/*",
dictDefaultMessage: "Drop files here or click to upload",
init: function() {
this.on("success", function(file, response) {
console.log("Upload successful:", file.name);
});
this.on("error", function(file, errorMessage) {
console.error("Upload failed:", errorMessage);
});
}
};
</script>
<form action="/"
class="dropzone"
id="my-dropzone"></form>
</body>
</html>
+7 -1
View File
@@ -4,9 +4,15 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Success - Upload Music</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}" type="text/css" />
<style>
body {
background-color: #2B2726;
color: #FFFFFF;
}
</style>
</head>
<body>
<button onclick="window.location.href='/outpost.goauthentik.io/sign_out'">Logout</button>
<h1>Success</h1>
<p>{{ success_message }}</p>
<a href="/"><button>Upload another file</button></a>