Flesh out API
This commit is contained in:
+28
-5
@@ -1,4 +1,4 @@
|
||||
from flask import Flask, render_template, request, jsonify, url_for
|
||||
from flask import Flask, render_template, request, jsonify
|
||||
from .controller import Controller
|
||||
|
||||
|
||||
@@ -14,8 +14,9 @@ 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", 5800))
|
||||
controller.connect(host, port)
|
||||
port: int = int(request.args.get("port", 9800))
|
||||
|
||||
return controller.connect(host, port)
|
||||
|
||||
|
||||
@app.route("/api/soundfonts")
|
||||
@@ -29,7 +30,29 @@ def instruments():
|
||||
return jsonify(controller.get_instruments(font))
|
||||
|
||||
|
||||
@app.route("/", defaults={"path": ""})
|
||||
@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("/")
|
||||
@app.route("/<path:path>")
|
||||
def index(path: str):
|
||||
def index(path: str = ""):
|
||||
print(f"PATH: {path}")
|
||||
return render_template("index.html")
|
||||
|
||||
|
||||
@app.errorhandler(404)
|
||||
def not_found(*args, **kwargs):
|
||||
return render_template("index.html")
|
||||
|
||||
Reference in New Issue
Block a user