Exemplo n.º 1
0
def index(request):
    """
    weibo 首页的路由函数
    """
    u = current_user(request)
    ws = Weibo.find_all(user_id=u.id)
    return html_response('weibo_index.html', weibos=ws, user=u)
Exemplo n.º 2
0
def index():
    """
    weibo 首页的路由函数
    """
    u = current_user()
    weibos = Weibo.find_all(user_id=u.id)
    return render_template('weibo_index.html', weibos=weibos, user=u)
Exemplo n.º 3
0
def index(request):
    """
    weibo 首页的路由函数
    """
    u = current_user(request)
    weibos = Weibo.find_all(user_id=u.id)
    # 替换模板文件中的标记字符串
    body = AyuTemplate.render('weibo_index.html', weibos=weibos, user=u)
    return html_response(body)
Exemplo n.º 4
0
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.find_all(user_id=author_id)
    body = template('weibo_index.html', weibos=weibos, user=user)
    return http_response(body)
Exemplo n.º 5
0
def index(request):
    user_id = request.query.get('user_id', -1)
    user_id = int(user_id)
    user = User.find(user_id)
    if user is None:
        return redirect('/login')
    # 找到 user 发布的所有 weibo
    weibos = Weibo.find_all(user_id=user_id)
    body = template('weibo_index.html', weibos=weibos, user=user)
    return http_response(body)
Exemplo n.º 6
0
def index(request):
    """
    weibo 首页的路由函数
    """
    # 找到当前登录的用户, 如果没登录, 就 redirect 到 /login
    uname = current_user(request)
    user = User.find_by(username=uname)
    if user is None:
        return redirect('/login')
    weibos = Weibo.find_all(user_id=user.id)
    body = template('weibo_index.html', weibos=weibos, user=user)
    return http_response(body)
Exemplo n.º 7
0
def index(request):
    """
    用户 weibo 的主页, 前往路径为 /weibo/index?user_id=1
    该页面不登录也可以访问
    """
    user_id = int(request.query.get('user_id', -1))
    user = User.find_by(id=user_id)
    if user is None:
        return redirect('/login')
    weibos = Weibo.find_all(user_id=user_id)
    # 找到 user 发布的所有 weibo
    body = j_template('weibo_index.html', user=user, weibos=weibos)
    return http_response(body)
Exemplo n.º 8
0
def index(request):
    headers = {
        'Content-Type': 'text/html',
    }
    header = response_with_headers(headers)
    user_id = request.query.get('user_id', -1)
    user_id = int(user_id)
    user = User.find(user_id)
    if user is None:
        return redirect('/login')
    # 找到 user 发布的所有 weibo
    weibos = Weibo.find_all(user_id=user_id)
    body = template('weibo_index.html', weibos=weibos, user=user)
    r = header + '\r\n' + body
    return r.encode(encoding='utf-8')
Exemplo n.º 9
0
def index(request):
    """
    用户 weibo 的主页, 前往路径为 /weibo/index?user_id=1
    该页面不登录也可以访问
    """
    current = False
    user_id = int(request.query.get('user_id', -1))
    u_id = int(current_user_id(request))
    if u_id is not None and u_id == user_id:
        # 说明当前用户不是该微博的主人
        current = True
    user = User.find_by(id=user_id)
    weibos = Weibo.find_all(user_id=user_id)
    # 找到 user 发布的所有 weibo
    body = j_template('weibo_index.html', user=user, weibos=weibos, current=current)
    return http_response(body)
Exemplo n.º 10
0
def index(request):
    """
    weibo 首页的路由函数
    """
    # 查看query中是否存在user_id
    # 存在,查看user_id用户的所有微博
    if 'user_id' in request.query:
        user_id = request.query['user_id']
        u = User.find_by(id=int(user_id))

    # 不存在,查看user_id用户的所有微博
    else:
        u = current_user(request)
        user_id = u.id

    weibos = Weibo.find_all(user_id=int(user_id))
    # 替换模板文件中的标记字符串
    return html_response('weibo_index.html', weibos=weibos, user=u)
Exemplo n.º 11
0
def index(request):
    user_id = int(request.query.get('user_id', -1))
    user = User.find_by(id=user_id)
    weibos = Weibo.find_all(user_id=user_id)
    body = templates('weibo_index.html', weibos=weibos, user=user)
    return http_response(body)
Exemplo n.º 12
0
Arquivo: weibo.py Projeto: zjy45/weibo
def index():
    all_weibo = Weibo.find_all(deleted=False)
    return render_template('weibo/weibo.html', weibo=all_weibo)
Exemplo n.º 13
0
def index(request):
    u = current_user(request)
    weibos = Weibo.find_all(user_id=u.id)
    body = template('weibo_index.html', weibos=weibos, user=u)
    return http_response(body)