기본 콘텐츠로 건너뛰기

Flask 12. 로그아웃

Flask 12. 로그아웃

로그인은 세션에 userid만 등록해주면 됐다. 그러면 로그아웃은 반대로 세션에서 userid만 삭제해주면 된다.

@app.route('/logout', methods=['GET']) # POST는 필요없다. def logout(): session.pop('userid', None) return redirect('/')

그리고 로그인을 했을 경우에 route 경로에 로그아웃 버튼이 나오도록 설정한다.

{%if userid%} {{userid}} 로그아웃 {%endif%}

from http://ohdowon064.tistory.com/123 by ccl(A) rewrite - 2020-03-11 16:20:10

댓글

이 블로그의 인기 게시물

Flask 13. pythonanywhere에 배포하기

Flask 13. pythonanywhere에 배포하기 Login: PythonAnywhere It's always a pleasure to hear from you! Ask us a question, or tell us what you love or hate about PythonAnywhere. We'll get back to you over email ASAP. Sorry, there was an error connecting to the server. Please try again in a few moments... www.pythonanywhere.com from http://ohdowon064.tistory.com/124 by ccl(A) rewrite - 2020-03-11 15:54:10

[ubuntu] FLASK_APP

[ubuntu] FLASK_APP Development/Debugging 🐞 FLASK_ENV=development FLASK_APP = app.py flask run zsh: command not found: FLASK_APP ✔️ FLASK_ENV=development FLASK_APP=app.py flask run 띄어쓰기를 해서 저런 오류를 출력할수도 있구나 😲 참고 : 108p에서 FLASK가 FKAS로 오타나있다. from http://hee-stories.tistory.com/18 by ccl(A) rewrite - 2020-03-24 17:20:11