Ejemplo n.º 1
0
def save_info():
    data = request.get_json(silent=True)
    http_uid = data.get('http_uid')
    url = data.get('url')
    method = data.get('method')
    code = data.get('code')
    info = json.loads(data.get('info'))
    with db.auto_commit():
        CGI.save(http_uid=http_uid,
                 url=url,
                 method=method,
                 code=code,
                 info=info)
    return Success()
Ejemplo n.º 2
0
 def get_target_list(self, target_option):
     db.session.close()
     target_list = [{
         'uid': cgi.uid,
         'target': cgi.info
     } for cgi in CGI.list_items_paginate_by_search(**target_option)]
     return target_list
Ejemplo n.º 3
0
def activate():
    data = request.get_json(silent=True)
    uid = data.get('uid')
    c = CGI.get_item_by_uid(uid, status=0)
    with db.auto_commit():
        c.activate()
    return Success()
Ejemplo n.º 4
0
def get_list():
    page_no = request.args.get('pageNo', 1, type=int)
    page_size = request.args.get('pageSize', 10, type=int)
    uid = request.args.get('uid', '', type=str)
    http_uid = request.args.get('http_uid', '', type=str)
    url = request.args.get('url', '', type=str)
    method = request.args.get('method', '', type=str)
    code = request.args.get('code', 200, type=int)
    status = request.args.get('status', 1, type=int)
    pagination = CGI.list_items_paginate_by_search(page=page_no,
                                                   per_page=page_size,
                                                   uid=uid,
                                                   status=status,
                                                   http_uid=http_uid,
                                                   url=url,
                                                   method=method,
                                                   code=code)
    data = {
        'pageSize':
        pagination.per_page,
        'pageNo':
        pagination.page,
        'totalCount':
        pagination.total,
        'data': [{
            'uid': c.uid,
            'http_uid': c.http_uid,
            'url': c.url,
            'method': c.method,
            'code': c.code,
            'status': c.status,
            'info': c.info
        } for c in pagination.items]
    }
    return Success(msg=data)
Ejemplo n.º 5
0
def remove():
    data = request.get_json(silent=True)
    uid = data.get('uid')
    c = CGI.get_item_by_uid(uid)
    with db.auto_commit():
        c.remove()
    return Success()
Ejemplo n.º 6
0
def update_info():
    data = request.get_json(silent=True)
    uid = data.get('uid')
    http_uid = data.get('http_uid')
    url = data.get('url')
    method = data.get('method')
    code = data.get('code')
    info = json.loads(data.get('info'))
    c = CGI.get_item_by_uid(uid=uid)
    with db.auto_commit():
        c.update(http_uid=http_uid,
                 url=url,
                 method=method,
                 code=code,
                 info=info)
    return Success()
Ejemplo n.º 7
0
def get_cgi():
    page_no = request.get('pageNo', 1, type=int)
    page_size = request.args.get('pageSize', 10, type=int)
    uid = request.args.get('uid', '', type=str)
    http_uid = request.args.get('http_uid', '', type=str)
    url = request.args.get('url', '', type=str)
    method = request.args.get('method', '', type=str)
    code = request.args.get('code', 200, type=int)
    pagination = CGI.list_items_paginate_by_search(page=page_no,
                                                   per_page=page_size,
                                                   uid=uid,
                                                   http_uid=http_uid,
                                                   url=url,
                                                   method=method,
                                                   code=code)
    return Success(msg=pagination)