Javascript Can';t在js+上重定向;瓶子
我有用于注销的烧瓶urlJavascript Can';t在js+上重定向;瓶子,javascript,python,redirect,flask-login,Javascript,Python,Redirect,Flask Login,我有用于注销的烧瓶url @app.route('/logout', methods = ['GET', 'POST']) @login_required def logout(): leave_room(str(current_user.code), sid = current_user.name, namespace='/') socketio.emit('left_user', current_user.name, room=str(current_user.code))
@app.route('/logout', methods = ['GET', 'POST'])
@login_required
def logout():
leave_room(str(current_user.code), sid = current_user.name, namespace='/')
socketio.emit('left_user', current_user.name, room=str(current_user.code))
db.session.delete(Users.query.filter_by(name=current_user.name).first())
db.session.commit()
logout_user()
flash('You are logged out', 'success')
return redirect(url_for('login'))
如果我在html中单击下面的链接,那就行了
<a class="navbar-brand text-center" href = '/logout'>Exit</a>
如何解决这个问题 我通过删除@login\u required解决了这个问题 现在/注销看起来是这样的:
@app.route('/logout', methods = ['GET', 'POST'])
def logout():
if current_user.is_anonymous:
return redirect(url_for('login'))
else:
leave_room(str(current_user.code), sid = current_user.name, namespace='/')
socketio.emit('left_user', current_user.name, room=str(current_user.code))
db.session.delete(Users.query.filter_by(name=current_user.name).first())
db.session.commit()
logout_user()
flash('You are logged out', 'success')
return redirect(url_for('login'))
@app.route('/logout', methods = ['GET', 'POST'])
def logout():
if current_user.is_anonymous:
return redirect(url_for('login'))
else:
leave_room(str(current_user.code), sid = current_user.name, namespace='/')
socketio.emit('left_user', current_user.name, room=str(current_user.code))
db.session.delete(Users.query.filter_by(name=current_user.name).first())
db.session.commit()
logout_user()
flash('You are logged out', 'success')
return redirect(url_for('login'))