-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
32 lines (24 loc) · 859 Bytes
/
test.py
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
30
31
32
from flask import Flask, render_template, flash, request
from wtforms import Form, TextField, TextAreaField, validators, StringField, SubmitField
# App config.
#DEBUG = True
app = Flask(__name__)
app.config.from_object(__name__)
app.config['SECRET_KEY'] = '7d441f27d441f27567d441f2b6176a'
class ReusableForm(Form):
name = TextField('Name:', validators=[validators.required()])
@app.route("/", methods=['GET', 'POST'])
def hello():
form = ReusableForm(request.form)
print form.errors
if request.method == 'POST':
name=request.form['name']
print name
if form.validate():
# Save the comment here.
flash('Hello ' + name)
else:
flash('All the form fields are required. ')
return render_template('hello.html', form=form)
if __name__ == "__main__":
app.run()