|
|
@ -19,7 +19,7 @@ Blueprints for Senpy
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
from flask import (Blueprint, request, current_app, render_template, url_for,
|
|
|
|
from flask import (Blueprint, request, current_app, render_template, url_for,
|
|
|
|
jsonify)
|
|
|
|
jsonify)
|
|
|
|
from .models import Error, Response, Help, Plugins, read_schema, Datasets
|
|
|
|
from .models import Error, Response, Help, Plugins, read_schema, dump_schema, Datasets
|
|
|
|
from . import api
|
|
|
|
from . import api
|
|
|
|
from .version import __version__
|
|
|
|
from .version import __version__
|
|
|
|
from functools import wraps
|
|
|
|
from functools import wraps
|
|
|
@ -67,9 +67,9 @@ def index():
|
|
|
|
@api_blueprint.route('/schemas/<schema>')
|
|
|
|
@api_blueprint.route('/schemas/<schema>')
|
|
|
|
def schema(schema="definitions"):
|
|
|
|
def schema(schema="definitions"):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
return jsonify(read_schema(schema))
|
|
|
|
return dump_schema(read_schema(schema))
|
|
|
|
except Exception: # Should be FileNotFoundError, but it's missing from py2
|
|
|
|
except Exception as ex: # Should be FileNotFoundError, but it's missing from py2
|
|
|
|
return Error(message="Schema not found", status=404).flask()
|
|
|
|
return Error(message="Schema not found: {}".format(ex), status=404).flask()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def basic_api(f):
|
|
|
|
def basic_api(f):
|
|
|
@ -133,6 +133,7 @@ def api_root():
|
|
|
|
req = api.parse_call(request.parameters)
|
|
|
|
req = api.parse_call(request.parameters)
|
|
|
|
return current_app.senpy.analyse(req)
|
|
|
|
return current_app.senpy.analyse(req)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@api_blueprint.route('/evaluate/', methods=['POST', 'GET'])
|
|
|
|
@api_blueprint.route('/evaluate/', methods=['POST', 'GET'])
|
|
|
|
@basic_api
|
|
|
|
@basic_api
|
|
|
|
def evaluate():
|
|
|
|
def evaluate():
|
|
|
@ -145,6 +146,7 @@ def evaluate():
|
|
|
|
response = current_app.senpy.evaluate(params)
|
|
|
|
response = current_app.senpy.evaluate(params)
|
|
|
|
return response
|
|
|
|
return response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@api_blueprint.route('/plugins/', methods=['POST', 'GET'])
|
|
|
|
@api_blueprint.route('/plugins/', methods=['POST', 'GET'])
|
|
|
|
@basic_api
|
|
|
|
@basic_api
|
|
|
|
def plugins():
|
|
|
|
def plugins():
|
|
|
|