repo init
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
venv/
|
||||||
|
setup.sh
|
||||||
|
navidrome-upload.service
|
||||||
45
main.py
Normal file
45
main.py
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import os
|
||||||
|
from flask import Flask, flash, request, redirect
|
||||||
|
from werkzeug.utils import secure_filename
|
||||||
|
|
||||||
|
UPLOAD_FOLDER = '/opt/navidrome/music'
|
||||||
|
ALLOWED_EXTENSIONS = {'flac', 'mp3', 'wav'}
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
|
||||||
|
|
||||||
|
def allowed_file(filename):
|
||||||
|
return '.' in filename and \
|
||||||
|
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
||||||
|
|
||||||
|
@app.route('/', methods=['GET', 'POST'])
|
||||||
|
def upload_file():
|
||||||
|
if request.method == 'POST':
|
||||||
|
# check if the post request has the file part
|
||||||
|
if 'file' not in request.files:
|
||||||
|
flash('No file part')
|
||||||
|
return redirect(request.url)
|
||||||
|
file = request.files['file']
|
||||||
|
# If the user does not select a file, the browser submits an
|
||||||
|
# empty file without a filename.
|
||||||
|
if file.filename == '':
|
||||||
|
flash('No selected file')
|
||||||
|
return redirect(request.url)
|
||||||
|
if file and allowed_file(file.filename):
|
||||||
|
filename = secure_filename(file.filename)
|
||||||
|
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
|
||||||
|
# File saved successfully, return a success message
|
||||||
|
return f'File {filename} uploaded successfully', 200
|
||||||
|
return '''
|
||||||
|
<!doctype html>
|
||||||
|
<title>Upload new File</title>
|
||||||
|
<button onclick="window.location.href='/outpost.goauthentik.io/sign_out'">Logout</button>
|
||||||
|
<h1>Upload new File</h1>
|
||||||
|
<form method=post enctype=multipart/form-data>
|
||||||
|
<input type=file name=file>
|
||||||
|
<input type=submit value=Upload>
|
||||||
|
</form>
|
||||||
|
'''
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(host='192.168.2.24', port=5001, debug=False)
|
||||||
7
requirements.txt
Normal file
7
requirements.txt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
blinker==1.9.0
|
||||||
|
click==8.3.1
|
||||||
|
Flask==3.1.2
|
||||||
|
itsdangerous==2.2.0
|
||||||
|
Jinja2==3.1.6
|
||||||
|
MarkupSafe==3.0.3
|
||||||
|
Werkzeug==3.1.5
|
||||||
Reference in New Issue
Block a user