35 lines
778 B
Python
35 lines
778 B
Python
import threading
|
|
|
|
from flask import Blueprint, current_app, jsonify, request
|
|
|
|
from runner import run_tests, get_status, load_config, save_config
|
|
|
|
bp = Blueprint("api", __name__)
|
|
|
|
|
|
@bp.route("/api/run", methods=["POST"])
|
|
def api_run():
|
|
t = threading.Thread(
|
|
target=run_tests,
|
|
args=(current_app.config["NUBES_API_ENDPOINT"], current_app.config["NUBES_API_TOKEN"]),
|
|
daemon=True,
|
|
)
|
|
t.start()
|
|
return jsonify({"ok": True})
|
|
|
|
|
|
@bp.route("/api/status")
|
|
def api_status():
|
|
return jsonify(get_status() or {})
|
|
|
|
|
|
@bp.route("/api/config", methods=["GET"])
|
|
def api_config_get():
|
|
return jsonify(load_config())
|
|
|
|
|
|
@bp.route("/api/config", methods=["POST"])
|
|
def api_config_save():
|
|
save_config(request.get_json())
|
|
return jsonify({"ok": True})
|