Example #1
0
def create_code():
    '''创建代码'''
    if not g.current_user:
        return BaseResponse.return_unauthorized('请先登录')
    args = request.json
    item = Code.create_or_update(**args)
    return BaseResponse.return_success(item.format())
Example #2
0
def create_visitor_log():
    '''生成访问记录'''
    args = request.json
    headers = request.headers
    ua = headers.get('user_agent')
    args['user_agent'] = ua
    res = VisitorLog.visit(**args)
    return BaseResponse.return_success(res.format())
Example #3
0
def wapi_test():
    '''测试'''
    res = {}
    res.update(dict(path=request.path))
    res.update(dict(method=request.method))
    res.update(dict(args=request.args))
    res.update(dict(json=request.json))
    res.update(dict(form=request.form))
    res.update(dict(headers=dict(request.headers)))
    return BaseResponse.return_success(res)
Example #4
0
def test():
    ''''''
    return BaseResponse.return_success()
Example #5
0
def code_detail(id):
    '''获取详情'''

    item = Code.query_by_id(id)
    print(item)
    return BaseResponse.return_success(item.format())
Example #6
0
def upload():
    '''创建代码'''
    logger.debug(request.files)
    return BaseResponse.return_success()
Example #7
0
def crawler_article():
    '''创建'''
    args = request.json
    url = args['url']
    res = Article.crawler(url=url)
    return BaseResponse.return_success(res.format())
Example #8
0
def update_article(id):
    '''更新文章'''
    res = Article.query_by_id(id)
    res.crawler_self()
    return BaseResponse.return_success(res.format())
Example #9
0
def create_auto_id(shard_id, item_id):
    '''生成id'''
    id = AutoId.generate_id(shard_id, item_id)
    return BaseResponse.return_success({"id": id})