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())
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())
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)
def test(): '''''' return BaseResponse.return_success()
def code_detail(id): '''获取详情''' item = Code.query_by_id(id) print(item) return BaseResponse.return_success(item.format())
def upload(): '''创建代码''' logger.debug(request.files) return BaseResponse.return_success()
def crawler_article(): '''创建''' args = request.json url = args['url'] res = Article.crawler(url=url) return BaseResponse.return_success(res.format())
def update_article(id): '''更新文章''' res = Article.query_by_id(id) res.crawler_self() return BaseResponse.return_success(res.format())
def create_auto_id(shard_id, item_id): '''生成id''' id = AutoId.generate_id(shard_id, item_id) return BaseResponse.return_success({"id": id})