from flask import Flask, render_template, request, jsonify from .controller import Controller app = Flask(__name__, static_folder="./client/build", static_url_path="/assets") controller = Controller() @app.route("/api/connect") def connect(): host: str = request.args.get("host", "0.0.0.0") port: int = int(request.args.get("port", 9800)) return controller.connect(host, port) @app.route("/api/soundfonts") def soundfonts(): return jsonify(controller.get_soundfonts()) @app.route("/api/instruments") def instruments(): font: int = int(request.args.get("font", 0)) return jsonify(controller.get_instruments(font)) @app.route("/api/select") def select(): channel: int = int(request.args.get("channel", 0)) instrument: int = int(request.args.get("instrument", 0)) bank: int = int(request.args.get("bank", 0)) program: int = int(request.args.get("program", 0)) return jsonify(controller.select(channel, instrument, bank, program)) @app.route("/api/gain") def gain(): amount: int = int(request.args.get("gain", 3)) return jsonify(controller.set_gain(amount)) @app.route("/", defaults={"path": ""}) @app.route("/") def index(path: str): return render_template("index.html.j2") # @app.errorhandler(404) # def not_found(*args, **kwargs): # return render_template("index.html.j2")