Upload 2 files
Browse files- main.py +24 -0
- templates/player.html +0 -0
main.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, render_template, send_file
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
app = Flask(__name__)
|
| 5 |
+
|
| 6 |
+
# Путь к папке с музыкой (предполагается, что файлы уже скачаны)
|
| 7 |
+
MUSIC_FOLDER = 'static/music'
|
| 8 |
+
|
| 9 |
+
@app.route('/')
|
| 10 |
+
def index():
|
| 11 |
+
# Получаем список музыкальных файлов
|
| 12 |
+
music_files = []
|
| 13 |
+
for file in os.listdir(MUSIC_FOLDER):
|
| 14 |
+
if file.endswith(('.mp3', '.wav', '.ogg')):
|
| 15 |
+
music_files.append(file)
|
| 16 |
+
return render_template('player.html', music_files=music_files)
|
| 17 |
+
|
| 18 |
+
@app.route('/music/<path:filename>')
|
| 19 |
+
def serve_music(filename):
|
| 20 |
+
# Безопасная отправка файла
|
| 21 |
+
return send_file(os.path.join(MUSIC_FOLDER, filename))
|
| 22 |
+
|
| 23 |
+
if __name__ == '__main__':
|
| 24 |
+
app.run(debug=True)
|
templates/player.html
ADDED
|
File without changes
|