daily pastebin goal
15%
SHARE
TWEET

Main Function

a guest Sep 21st, 2018 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from flask import Flask, flash, redirect, render_template, request, url_for
  2. app = Flask(__name__)
  3. app.secret_key = 'random string'
  4.  
  5. @app.route('/')
  6. def index():
  7.     return render_template('index.html')
  8.  
  9. @app.route('/login', methods = ['GET', 'POST'])
  10. def login():
  11.     error = None
  12.    
  13.     if request.method == 'POST':
  14.         if request.form['username'] != 'admin' or \
  15.             request.form['password'] != 'admin':
  16.             error = 'Invalid username or password. Please try again!'
  17.         else:
  18.             flash('You were successfully logged in')
  19.             do_stuff()
  20.             return redirect(url_for('index'))
  21.            
  22.     return render_template('login.html', error = error)
  23.  
  24. def do_stuff():
  25.     print("here")
  26.  
  27.  
  28. if __name__ == "__main__":
  29.     app.run(debug = True)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top