async def search(request): ''' url http://localhost:5000/v1/book/search?q={} ''' form = BookSearchForm(data=request.raw_args) if BookSearchForm(data=request.raw_args).validate(): book=Book(request) q=form.q.data result=await book.search_by_title_or_publisher(q) if result: resp={"result":result,"flag": 1} #返回值拼接成json格式 return json(resp) return NotFound(request) return ParameterException(request)
async def location_search(request): short_code = get_shortcode(request.raw_args['q']) if short_code: return json({"result": short_code}) return NotFound(request)
async def amazon_get_detail(request): url = request.raw_args['url'] if url: data = get_goods_detail(url) return json({"result": data}) return NotFound(request)
async def super_get_user(request,uid): user = User(request=request) result = await user.select_information("id", uid) if result: return json(result) return NotFound(request)
async def delete_user(request): user = User(request=request) result = await user.delete_user_by_id(request.headers["user_info"].uid) if result: return DeleteSuccess(request) return NotFound(request)
async def super_delete_user(request,uid): user = User(request=request) result = await user.delete_user_by_id(uid) if result: return DeleteSuccess(request) return NotFound(request)
async def detail(request,isbn): book = Book(request) result=await book.search_single_book("isbn",isbn) if result: return json(result) return NotFound(request)