コード例 #1
0
    def GET(self):
        try:
            sql = SqlManager()
            inputs = web.input()
            name = inputs.get('name')
            anonymity = inputs.get('anonymity', '%')
            https = inputs.get('https', '%')
            order = inputs.get('order', 'speed')
            sort = inputs.get('sort', 'asc')
            count = inputs.get('count', 100)

            kwargs = {
                'anonymity': anonymity,
                'https': https,
                'order': order,
                'sort': sort,
                'count': count
            }
            result = sql.select_proxy(name, **kwargs)
            data = [{
                'id': item[0], 'ip': item[1], 'port': item[2], 'anonymity': item[4], 'https': item[5],
                'speed': item[6], 'save_time': str(item[8])
            } for item in result]

            data = json.dumps(data, indent = 4)
            return data
        except Exception, e:
            logging.exception('select exception msg:%s' % e)
コード例 #2
0
def select():
    sql = SqlManager()
    name = request.args.get('name')
    anonymity = request.args.get('anonymity', '')
    https = request.args.get('https', '')
    order = request.args.get('order', 'speed')
    sort = request.args.get('sort', 'asc')
    count = request.args.get('count', 100)

    kwargs = {
        'anonymity': anonymity,
        'https': https,
        'order': order,
        'sort': sort,
        'count': count
    }
    result = sql.select_proxy(name, **kwargs)
    data = [{
        'ip': item.get('ip'),
        'port': item.get('port'),
        'anonymity': item.get('anonymity'),
        'https': item.get('https'),
        'speed': item.get('speed'),
        'save_time': item.get('save_time', '')
    } for item in result]
    return json.dumps(data, indent=4)