-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
33 lines (28 loc) · 1023 Bytes
/
app.py
File metadata and controls
33 lines (28 loc) · 1023 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
30
31
32
33
from flask import Flask, render_template, request, redirect, url_for
from forms import ToDo
#set of commands to change env.
#> set FLASK_APP=flaskr
#set FLASK_ENV=development
#flask run
app = Flask(__name__)
app.config['SECRET_KEY'] = 'password'
@app.route('/', methods =['GET', 'POST'])
def home():
request_method = request.method
if request.method == 'POST':
first_name = request.form['first_name']
last_name = request.form['last_name']
return redirect(url_for('name', first_name = first_name))
return render_template('hello.html', request_method = request_method)
@app.route('/name/<string:first_name>')
def name(first_name):
return f'{first_name}'
@app.route('/todo', methods = ['GET', 'POST'])
def todo():
todo_form = ToDo()
if todo_form.validate_on_submit():
print(todo_form.content.data)
return redirect('/')
return render_template('todo.html', form=todo_form)
if __name__ == '__main__':
app.run(debug=True)