aboutsummaryrefslogtreecommitdiff
path: root/gn3/api/ctl.py
blob: 0844c956fc655010c230f801b26c8c554f1ecd29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""module contains endpoints for ctl"""

# so small

from flask import Blueprint
from flask import request
from flask import jsonify

from gn3.computations.ctl import call_ctl_script

ctl = Blueprint("ctl", __name__)


@ctl.route("/run_ctl", methods=["POST"])
def run_ctl():
    """endpoint to run ctl"""
    ctl_data = request.json

    (cmd_results, response) = call_ctl_script(ctl_data)
    return (jsonify({
        "results": results
    }), 200) if response is not None else (jsonify({"error": str(cmd_results)}), 401)