blob: 3bd11ea42019bb3bd2a76f89451faf8abe36923b (
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
"""
Rhizi web API
"""
import os
import db_controller as dbc
import json
from flask import jsonify
from flask import Flask
from flask import request
webapp = Flask(__name__)
webapp.debug = True
# injected: DB controller
db_ctl = None
def __sanitize_input():
pass
def __response_wrap(data=None, error=None):
"""
wrap response data/errors as dict - this should always be used when returning
data to allow easy return of list objects, assist in error case distinction, etc.
"""
return dict(data=data, error=error)
@webapp.route("/load/node-single", methods=['POST'])
def load_node_by_id_attr():
"""
@return: a list containing a single node whose id attribute matches 'id' or
an empty list if the requested node is not found
@raise exception: on error
"""
node_id = request.form['id']
__sanitize_input(node_id)
op = dbc.DBO_load_node_set_by_id_attribute([node_id])
try:
n = db_ctl.exec_op(op)
ret = __response_wrap(data=n)
return jsonify(ret)
except Exception as e:
return jsonify(__response_wrap(error='unable to load node with id: {0}'.format(node_id)))
@webapp.route("/add/node-single", methods=['POST'])
def add_node(n):
pass
@webapp.route("/add/node-set", methods=['POST'])
def add_node_set(n_set):
op = dbc.DBO_add_node_set()
pass
|