1 changed files with 29 additions and 0 deletions
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
from flask import Flask, render_template, send_file, jsonify |
||||
import json |
||||
import os |
||||
|
||||
app = Flask(__name__) |
||||
|
||||
# Configuration |
||||
MUSIC_DIR = 'static/audio' |
||||
COVERS_DIR = 'static/covers' |
||||
|
||||
@app.route('/') |
||||
def index(): |
||||
return render_template('index.html') |
||||
|
||||
@app.route('/tracks') |
||||
def get_tracks(): |
||||
with open('musicplayer/tracks.json') as f: |
||||
return jsonify(json.load(f)) |
||||
|
||||
@app.route('/audio/<path:filename>') |
||||
def serve_audio(filename): |
||||
return send_file(os.path.join(MUSIC_DIR, filename)) |
||||
|
||||
@app.route('/cover/<path:filename>') |
||||
def serve_cover(filename): |
||||
return send_file(os.path.join(COVERS_DIR, filename)) |
||||
|
||||
if __name__ == '__main__': |
||||
app.run(debug=True) |
||||
Loading…
Reference in new issue