-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
29 lines (21 loc) · 711 Bytes
/
Copy pathmain.py
File metadata and controls
29 lines (21 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from flask import Flask, render_template, flash, request
from wtforms import Form, validators, StringField
# App config.
DEBUG = True
app = Flask(__name__)
app.config.from_object(__name__)
app.config['SECRET_KEY'] = '7d441f27d441f27567d441f2b6176a'
class ReusableForm(Form):
name = StringField('Name:', validators=[validators.data_required()])
@app.route("/", methods=['GET', 'POST'])
def hello():
form = ReusableForm(request.form)
if request.method == 'POST':
if form.validate():
name = request.form['name']
flash('Hello ' + name)
else:
flash('All the form fields are required. ')
return render_template('hello.html', form=form)
if __name__ == "__main__":
app.run()