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

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
    input: request form object
    output:json object enum::(response,error)

    """
    ctl_data = request.json

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