Advertisement
Guest User

Untitled

a guest
Jan 14th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. @app.route('/login', methods=['GET','POST'])
  2. def login():
  3.     if request.method == 'GET':
  4.  
  5.         return render_template('login.html')
  6.     elif request.method == 'POST':
  7.         username = str(request.form['username'])
  8.         usertoShow = User.query.filter_by(username=username).first()
  9.         password = str(request.form['password'])
  10.         result = User.query.filter_by(username=username,password=password).first()
  11.         if result:
  12.             session['zalogowany'] = True
  13.             session['user_id'] = result.id
  14.         else:
  15.             flash(Markup('<p><font color="red">Zly login lub haslo.<br>Chcialbys sie </font><a href="/register">zarejestrowac?</a></p>'))
  16.         return render_template('login.html', user_show = usertoShow)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement