-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmit.py
More file actions
36 lines (29 loc) · 1.07 KB
/
submit.py
File metadata and controls
36 lines (29 loc) · 1.07 KB
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
33
34
35
36
from flask_wtf import Form
from wtforms import TextField
from wtforms.validators import DataRequired
from flask import Flask, request
from flask import render_template
app = Flask(__name__)
app.config['WTF_CSRF_ENABLED'] = False
class MyForm(Form):
name = TextField('name', validators=[DataRequired()])
@app.route('/user/username')
def show_user_profile():
# show the user profile for that user
user = request.args.get('username')
return 'User %s' % user
@app.route('/success', methods=('GET', 'POST'))
def success():
return "WTF!"
@app.route('/submit', methods=('GET', 'POST'))
def submit():
form = MyForm()
if form.validate_on_submit():
return redirect('/success')
#return render_template(r'C:\Users\ddye\Documents\PyBulls\teach-me-flask\templates\submit.html', form=form)
#return render_template(r'C:\Users\ddye\Documents\PyBulls\teach-me-flask\templates\submit.html')
#return render_template('submit.html')
#return "Hello!"
return render_template('submit.html', form=form)
app.run(port=5001, debug=True)
#app.run(port=5001)