def index(request): log('routes weibo index') u = current_user(request) weibos = Weibo.all(user_id=u.id) return html_response('weibo_index.html', weibos=weibos, user=u)
def all_weibo(request): """ 返回所有 todo """ ms = Weibo.all() # 单纯地从Weibo.txt中生成Weibo对象 # 要转换为 dict 格式才行 data = [m.json() for m in ms] # 把属于Weibo对象的所有comments加入到Weibo return json_response(data)
def index(request): """ weibo 页的路由函数, 返回 weibo 页面 """ weibos = Weibo.all() # 替换模板文件中的标记字符串 body = SeizerTemplate.render('weibo_index0.html') return html_response(body)
def index(): """ weibo 首页的路由函数 """ u = current_user() weibos = Weibo.all(user_id=u.id) # 替换模板文件中的标记字符串 return render_template('weibo_index.html', weibos=weibos, user=u)
def all_weibo(request): """ 返回所有 weibo """ ms = Weibo.all() # 要转换为 dict 格式才行 data = [m.json() for m in ms] return json_response(data)
def index(request): """ weibo 首页的路由函数 """ u = current_user(request) weibos = Weibo.all(user_id=u.id) # 替换模板文件中的标记字符串 return html_response('weibo_index.html', weibos=weibos, user=u)
def index(request): author_id = int(request.query.get('user_id', -1)) user = current_user(request) if author_id == -1: author_id = user.id weibos = Weibo.all() body = template('weibo_index.html', weibos=weibos, user=user) return http_response(body)
def all(request): """ 返回所有 weibo """ ms = Weibo.all() # 要转换为 dict 格式才行 ms = [m.json() for m in ms] print(ms) return json_response(ms)
def index(request): """ weibo 页的路由函数, 返回 weibo 页面 """ u = current_user(request) weibos = Weibo.all() # 替换模板文件中的标记字符串 body = HtmlTemplate.render('weibo_index.html', username=u.username) return html_response(body)
def all(request): w = Weibo.all() for i in w: c = Comment.all(weibo_id=i.id) x = [t.json() for t in c] s = json.dumps(x, ensure_ascii=False) i.comment = s i.save(i.__dict__) weibos = Weibo.all_json() return json_response(weibos)
def index(request): # if 'id' in request.query: # user_id = int(request.query['id']) # u = User.one(id=user_id) # else: # u = current_user(request) weibos = Weibo.all() return html_response('weibo_index.html', weibos=weibos)
def index(request): """ weibo 首页的路由函数 """ if 'user_id' in request.query: user_id = int(request.query['user_id']) else: u = current_user(request) user_id = u.id weibos = Weibo.all(user_id=user_id) return html_response('weibo_index.html', weibos=weibos)
def index(request): """ todo 首页的路由函数 """ if 'user_id' in request.query: user_id = int(request.query['user_id']) user = User.one(id=user_id) else: user = current_user(request) weibos = Weibo.all(user_id=user.id) return html_response('weibo_index.html', weibos=weibos, user=user)
def all(request): Weibos = Weibo.all() w = [] for weibo in Weibos: c = {'comments': [comment.json() for comment in weibo.comments()]} log('F_weibo_all{}'.format(c)) c['weibo'] = weibo.json() # w.append({weibo.id: c}) w.append(c) # log('<F aip_weibo all> Weibos, comments', w) return json_response(w)
def index(): u = current_user() weibos = Weibo.all(user_id=u.id) # weibos = Weibo.find_all() # 替换模板文件中的标记字符串 log('所有微博', weibos) # body = GuaTemplate.render('weibo_index.html', weibos=weibos, user=u) return render_template( 'weibo_index.html', weibos=weibos, user=u, )
def weibo_index(request): """ weibo 首页的路由函数 """ data = request.query if 'user_id' in data: u = User.one(id=int(data['user_id'])) else: u = current_user(request) weibos = Weibo.all(user_id=u.id) body = JinjaTemplate.render('weibo_index_ajax.html', weibos=weibos, user=u) return html_response(body)
def index(request): """ weibo 首页的路由函数 """ if 'id' in request.query: user_id = int(request.query['id']) u = User.one(id=user_id) else: u = current_user(request) weibos = Weibo.all(user_id=u.id) # 替换模板文件中的标记字符串 return html_response('weibo_index.html', weibos=weibos, user=u)
def index(request): """ weibo 首页的路由函数 """ if 'user_id' in request.query: user_id = int(request.query['user_id']) else: u = current_user(request) user_id = u.id weibos = Weibo.all(user_id=user_id) for w in weibos: print('w.dict', w.__dict__) # 替换模板文件中的标记字符串 return html_response('weibo_index.html', weibos=weibos)
def all(): """ weibo 首页的路由函数 """ weibo_list = [] weibos = Weibo.all() for weibo in weibos: form = weibo.json() comments = Comment.find_all(weibo_id=int(form['id'])) comments = [comment.json() for comment in comments] form['comments'] = comments weibo_list.append(form) log('json weibo_list in weibo all', weibo_list) return jsonify(weibo_list)
def index(): """ weibo 首页的路由函数 """ # u = current_user() # weibos = Weibo.all(user_id=u.id) # # 替换模板文件中的标记字符串 # return html_response('weibo_index.html', weibos=weibos, user=u) if 'id' in request.args: user_id = int(request.args['id']) u = User.one(id=user_id) else: u = current_user() weibos = Weibo.all(user_id=u.id) return render_template('weibo_index.html', weibos=weibos, user=u)
def all(request): # weibos = Weibo.all_json() weibos = Weibo.all() ws = [] for weibo in weibos: comments = weibo.comments() list = [] for comment in comments: comment.username = comment.user().username list.append(comment.json()) w = dict( content=weibo.content, created_time=weibo.created_time, updated_time=weibo.updated_time, id=weibo.id, comments=list, ) ws.append(w) return json_response(ws)
def all(): weibos = [] ws = Weibo.all() for w in ws: # 获得每个weibo对应的评论 cs = w.comments() comments = [] w_username = w.user().username # 序列化comment并为每个评论添加用户名 for c in cs: username = c.user().username c = c.json() c['username'] = username comments.append(c) w = w.json() # 将评论插入到对应的微博字典中 w['comments'] = comments w['username'] = w_username weibos.append(w) return jsonify(weibos)
def all(request): weibo_list = Weibo.all() # 要转换为 dict 格式才行 weibos = [t.json() for t in weibo_list] return json_response(weibos)
def all_weibo(request): ms = Weibo.all() data = [m.json() for m in ms] return json_response(data)
def index(request): u = current_user(request) weibos = Weibo.all(user_id=u.id) log('weibos', weibos) return html_response('weibo_index.html', weibos=weibos, user=u)
def all_weibo(request): weibo_list = Weibo.all() weibos = [weibo.json() for weibo in weibo_list] return json_response(weibos)
def index(request): u = current_user(request) weibos = Weibo.all() body = template('weibo_index.html', weibos=weibos, user=u) return http_response(body)