daily pastebin goal
58%
SHARE
TWEET

Untitled

a guest Mar 19th, 2019 110 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -success
  2. -email already exists
  3. -username already exists
  4.      
  5. from flask import Flask, render_template, request, redirect, url_for
  6.  
  7. import db.db_mgmt as db_mgmt
  8.  
  9. app = Flask(__name__)
  10.  
  11.  
  12. @app.route('/')
  13. @app.route('/signup')
  14. def signup():
  15.     return render_template('signup.html', message=result)
  16.  
  17.  
  18. @app.route('/submit_registration', methods=['POST'])
  19. def add_user():
  20.     username = request.form['username']
  21.     first = request.form['first']
  22.     last = request.form['last']
  23.     email = request.form['email']
  24.     password = request.form['password']
  25.     result = db_mgmt.add_user(username, first, last, email, password)
  26.  
  27.     if result == 'success':
  28.         return redirect(url_for('login'))
  29.     else:
  30.         return redirect(url_for('signup', message = result))
  31.  
  32.  
  33. @app.route('/login')
  34. def login():
  35.     return render_template('login.html')
  36.  
  37.  
  38. @app.route('/home', methods=['POST'])
  39. def homepage():
  40.     return "Welcome to your homepage"
  41.  
  42.  
  43. @app.route('/validate_login', methods=['POST'])
  44. def validate_login():
  45.     username = request.form['username']
  46.     password = request.form['password']
  47.  
  48.     if db_mgmt.login():
  49.         return redirect(url_for('homepage'))
  50.     else:
  51.         return redirect(url_for('login', message = 'Invalid Login'))
  52.  
  53.  
  54. app.run(debug=True, host='0.0.0.0', port=5000)
  55.      
  56. return render_template('signup.html', message=result)
  57.      
  58. return render_template('signup.html', message=result)
  59. NameError: name 'result' is not defined
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