Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. from flask import Flask, render_template
  2. from flask_wtf import FlaskForm
  3. from wtforms import StringField, PasswordField
  4.  
  5. app = Flask(__name__)
  6. app.config['SECRET_KEY'] = '123456'
  7.  
  8.  
  9. class LoginForm(FlaskForm):
  10. username = StringField('username')
  11. password = PasswordField('password')
  12.  
  13.  
  14. @app.route('/form', methods=['GET', 'POST'])
  15. def index():
  16. form = LoginForm()
  17. s = form.username.data
  18. s1 = form.password.data
  19. return f'Your username is {s} and your password is {s1}', render_template('index.html', form=form)
  20.  
  21.  
  22. if __name__ == "__main__":
  23. app.run(debug=True)
  24.  
  25.  
  26.  
  27. <!DOCTYPE html>
  28. <html>
  29. <head>
  30. <title>Form!</title>
  31. </head>
  32. <body>
  33. <h1>Our form will be here!</h1>
  34. <form method="GET" action="{{ url_for('index') }}">
  35. {{ form.csrf_token }}
  36. {{ form.username.label }}
  37. {{ form.username }}
  38. {{ form.password.label }}
  39. {{ form.password }}
  40. <input type="submit" value="Submit">
  41. </form>
  42. </body>
  43. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement