From 77e10982aa3444e669ff573b70aa9bdda5362561 Mon Sep 17 00:00:00 2001 From: Denis Tereshkin Date: Wed, 5 Mar 2025 23:25:31 +0700 Subject: [PATCH] Move app to __init__ --- __init__.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 __init__.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..9ababd9 --- /dev/null +++ b/__init__.py @@ -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/') +def serve_audio(filename): + return send_file(os.path.join(MUSIC_DIR, filename)) + +@app.route('/cover/') +def serve_cover(filename): + return send_file(os.path.join(COVERS_DIR, filename)) + +if __name__ == '__main__': + app.run(debug=True)