def add_comment(request): form = request.json() # 创建一个 model c = Comment.new(form) # 把创建好的 model 返回给浏览器 return json_response(c.json())
def add_comment(request): """ 接受浏览器发过来的添加 comment 请求 添加数据并返回给浏览器 """ form = request.json() # 创建一个 model m = Comment.new(form) # 把创建好的 model 返回给浏览器 return json_response(m.json())
def add_comment(request): """ 接受浏览器发过来的添加 comment 请求 添加数据并返回给浏览器 """ # 得到浏览器发送的表单, 浏览器用 ajax 发送 json 格式的数据过来 # 所以这里我们用新增加的 json 函数来获取格式化后的 json 数据 form = request.json() print('api add comment form', form) # 创建一个 comment c = Comment.new(form) # 把创建好的 weibo 返回给浏览器 return json_response(c.json())
def add_comment(request): """ 接受浏览器发过来的添加 weibo 请求 添加数据并返回给浏览器 """ log('add') form = request.json() # 创建一个 model c = Comment.new(form) # 把创建好的 model 返回给浏览器 log('return comment:', c.json()) log('***********', c) return json_response(c.json())
def add_comment(request): """ 接受浏览器发过来的添加 todo 请求 添加数据并返回给浏览器 """ # 得到浏览器发送的 json 格式数据 # 浏览器用 ajax 发送 json 格式的数据过来 # 所以这里我们用新增加的 json 函数来获取格式化后的 json 数据 form = request.json() # 字符串格式转化成dict c = Comment.new(form) cs = Comment.find_all(weibo_id=c.weibo_id) # 加载属于该微博的所有comment cs_list = [c.json() for c in cs] # 每一个对象转成dict return json_response(cs_list)
def add_comment(request): """ 接受浏览器发过来的添加 comment 请求 添加数据并返回给浏览器 """ # 将获得的请求转换为 json 格式的字符串 form = request.json() log('add_comnent form: ', form) # 创建一个 model m = Comment.new(form) log('m: ', m) # 把创建好的 model 返回给浏览器 log('add_weibo json_response(m.json()): ', json_response(m.json())) return json_response(m.json())
def add_comment(request): # 添加评论 """ 接受浏览器发过来的添加 comment 请求 添加数据并返回给浏览器 """ log('路由到了添加评论({})'.format(request)) form = request.json() log('接收到的前端的数据', form) # 创建一个 model m = Comment.new(form) log('创建的评论对象', m) # 把创建好的 model 返回给浏览器 return json_response(m.json()) pass
def add_comment(request): form = request.json() comment = Comment.new(form) return json_response(comment.json())
def comment_weibo(request): form = request.json() # wid = int(form.get('id')) cmt = Comment.new(form) return json_response(cmt.json())