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
30 changes: 29 additions & 1 deletion flask_app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
"""
Put your Flask app code here.
"""
"""

from flask import Flask, render_template, request

app = Flask(__name__)

@app.route('/')
def main():
make_profile()
return render_template('survey.html')

@app.route('/user', methods=['GET', 'POST'])
def make_profile():
print('hello')
try:
name = request.form['name']
age = request.form['age']
return render_template('profile.html', name=name, age=age)
except:
return

@app.route('/error')
def error():
return render_template('error.html')


if __name__ == '__main__':
app.debug = True
app.run()
9 changes: 7 additions & 2 deletions hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
"""

from flask import Flask
from flask import render_template

app = Flask(__name__)

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

if __name__ == '__main__':
app.run()
try:
app.run()
except:
sys.exit(1)
13 changes: 13 additions & 0 deletions templates/error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>
Error
</title>
</head>
<body>
<h1>OOPS</h1>
<p>There's nothing to see here...</p>
</form>
</body>
</html>
7 changes: 7 additions & 0 deletions templates/hello.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!doctype html>
<title>Hello from Flask</title>
{% if name %}
<h1>Hello {{ name }}!</h1>
{% else %}
<h1>Hello World!</h1>
{% endif %}
19 changes: 19 additions & 0 deletions templates/profile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html>
<head>
<title>
Profile
</title>
</head>
<body>
<h1>
{{name}}
</h1>
<p>
This is your profile!
</p>
Age: {{age}}<br>
Favorite ninja: Patrick Huston
</p>
</body>
</html>
22 changes: 22 additions & 0 deletions templates/survey.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<title>
Survey
</title>
</head>
<body>
<h1>HELLO</h1>
<p>Please fill out this form!</p>
<form action="/user" method="POST">
Name:<br>
<input type="text" name="name"><br>
Age:<br>
<input type="text" name="age"><br>
Favorite Ninja:<br>
<input type="text" name="ninja"><br>
<br>
<input type="submit" value="Submit">
</form>
</body>
</html>