Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@
"""

from flask import Flask
from flask import render_template
from flask import request

app = Flask(__name__)

@app.route('/')
def hello_world():
return 'Hello World!'
return render_template('index.html')

@app.route('/login/', methods=['GET','POST'])
def login(name=None, age=None, patrick=None):
return render_template('login.html', name=request.form['name'], age=request.form['age'], patrick=request.form['patrick'])

if __name__ == '__main__':
#app.debug = True
app.run()
17 changes: 17 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<title>
Hello World
</title>
</head>
<body>
<h1>Hello! Please input your name, age, and favorite SoftDes Ninja.</h1>
<form action="/login/", method="post">
Name: <input type="text" name="name"><br>
Age: <input type="text" name="age"><br>
Favorite SoftDes Ninja: <input type="text" name="patrick"><br>
<input type="submit" value="SUBMIT!">
</form>
</body>
</html>
11 changes: 11 additions & 0 deletions templates/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
{% if name and age %}
<h1>Profile</h1>
<h2>{{ name }}</h2>
Age: {{ age }}<br>
Favorite SoftDes Ninja: Patrick Huston
{% else %}
You forgot some information<br>
Click <a href="/">here</a>to go back
{% endif %}