You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
658 B
30 lines
658 B
|
9 months ago
|
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('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)
|