this is error same error coming when i am trying to logout fuction are not responding
so i am thinking may error in layout.html where it get triggered
<!doctype html>
<html>
<head>
{% if title %}
<title>User - {{ title }} </title>
{% else %}
<title>welcome users</title>
{% endif %}
</head>
<body>
<div>
User System:
<a href="{{ url_for('main_bp.home') }}">Home</a>
{% if current_user.is_anonymous %}
<a href="/signin">Login</a>
{% else %}
<a href="/profile">Profile</a>
<a href="/signout">{{('Logout') }}</a>
{% endif %}
</div>
{% block content %}{% endblock %}
</body>
</html>
also adding other file code ...........profile view........
import email
from flask import redirect,url_for,render_template,Blueprint,request
from flask_login import login_user,current_user
from v1.auth.token import token_required
from v1.models import User,Profile
from v1.form import EmptyForm
view_profile=Blueprint('view_profile', __name__,template_folder='/v1/templates')
@view_profile.route ('/profile')
@token_required
def profile():
if (request.method==["post"]):
user=User.query.filter_by(email=current_user.email).first_or_404()
form=EmptyForm()
return render_template('profile.html',
user=user,
form=form
)
............................logout function......
from flask import render_template, redirect,Blueprint,flash,session,url_for,request
from flask_login import logout_user, current_user, login_user
from v1.auth import token
from v1.auth.token import token_required
from v1.form import loginform
from v1.models import db,User
import datetime
import jwt
from v1.config import Config
sign_in=Blueprint ( 'sign_in',
__name__,
template_folder='template',
static_folder='static'
)
@sign_in.route('/signin',methods=['GET', 'POST'])
def login():
if current_user.is_authenticated:
return redirect(url_for('main_bp.home'))
form = loginform()
if form.validate_on_submit():
user = User.query.filter_by(email=form.email.data).first()
if user and User.check_password(password=form.password.data):
token = jwt.encode({
'user_id' : user._id,
'exp' : datetime.datetime.utcnow() + datetime.timedelta(minutes=45)
}, Config.SECRET_KEY, "HS256")
login_user(user)
flash("you are successfuly logged in")
return redirect(url_for('main_bp.home'))
flash('Invalid username/password combination')
return redirect(url_for('sign_in.login'))
return render_template(
'login.jinja2',
form=form,
title='Log in.',
template='login-page',
body="Log in with your User account."
)
@sign_in.route('/signout')
@token_required
def signout():
logout_user()
token=None
return redirect(url_for('auth.login'))
.......................profile html......................
{% extends "layout.jinja2" %}
{% block content %}
<table>
<tr valign="top">
<td>
<h1> {{user.name}}</h1>
{% if user == current_user %}
<p><a href="/edit_profile">Edit your profile</a></p>z
{% endif %}
<h2>User: {{ user.username }}</h2>
{% if user.about_me %}<p>{{ user.about_me }}</p>{% endif %}
</td>
<td></td>
<td><h2>{{user.email}}</h2></td>
</tr>
</table>
{% endblock %}