登录成功后,跳转到新页面,但是新页面不停的填充元素,最后崩溃

求问

执行重定向redirect函数函数后 跳转执行下面的user_index函数,
则打开index页面之后,
一直在重复动作:访问数据库、get请求skin_config.html(而实际上我的templates里并没有这个html)一直这样重复,但是页面还在index页面,
于是index.html页面一直在重复添加index的内容
导致页面越来越长,然后直到内存占用过多页面崩溃

redirect

 # 查询
        user = User.query.filter_by(username=username).first()
        if not user:
            flash("不存在该用户")
            return render_template('login/login.html', form=form)
        if user.password == password:
            return redirect(url_for("index.user_index", username=username))
        else:
            flash("密码输入错误")

user_index

@index_bp.route('/<string:username>', methods=["POST", "GET"], endpoint='user_index')
def user_index(username):
    if request.method == 'GET':
        user = User.query.filter_by(username=username).first()
        return render_template('index/index.html', user=user)
    else:
        return "not post now"

运行过程:

get打开login登录界面
post提交之后,验证用户名和密码,密码正确则执行重定向函数
然后就。。。。一直重复执行这一段

浏览器页面上不停的重复添加加载内容,页面越来越长:

而如果我不用重定向函数传参,而是用session把username传过去的话则正常运行:

    # 查询
        user = User.query.filter_by(username=username).first()
        if not user:
            flash("不存在该用户")
            return render_template('login/login.html', form=form)
        if user.password == password:
            session['username'] = username
            return redirect(url_for("index.user_index"))
        else:
            flash("密码输入错误")
@index_bp.route('/', methods=["POST", "GET"], endpoint='user_index')
def user_index():
    if request.method == 'GET':
        if 'username' in session:
            username = session['username']
            user = User.query.filter_by(username=username).first()
            return render_template('index/index.html', user=user)
        else:
            return "not username"
    else:
        return "not post now"