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
29 changes: 27 additions & 2 deletions hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,36 @@
"""

from flask import Flask
from flask import render_template, request, redirect
app = Flask(__name__)

@app.route('/hello/')
@app.route('/hello/<name>')
def hello(name=None):
return render_template('hello.html', name=name)

@app.route('/')
def hello_world():
return 'Hello World!'
print 'Hi'
#return 'Hello World!'
return render_template('register.html')

@app.route('/Register', methods=['GET', 'POST']) # The most useful
def register(name=None, age=None):
print "In Register"
if request.method == 'POST':
print "In Post thing"
return render_template('info.html')
print "Rendering register.html"
return render_template('register.html')

@app.route('/Info', methods=['GET', 'POST'])
#@app.route('/Info/<name>/<age>', methods=['GET, POST'])
def info():
print request.method
if request.method == 'POST':
return render_template('info.html', name=request.form['name'], age=request.form['age'])
return 'Nope'

if __name__ == '__main__':
app.run()
app.run()
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 %}
12 changes: 12 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>
A Small Hello
</title>
</head>
<body>
<h1>H9</h1>
<p> The best webpage </p>
</body>
</html>
9 changes: 9 additions & 0 deletions templates/info.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<title>Our intelligence services have gathered the following information:</title>
{% if name and age %}
<h1>Name: {{ name }}ski</h1>
<h1>Age: 1{{ age }}</h1>
<h1>Prefered Ninja: Patrick Hustonski</h1>
{% else %}
<h1>Shit.</h1>
{% endif %}
12 changes: 12 additions & 0 deletions templates/register.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<title>Give us your info, or else...</title>

<form action="/Info", 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>
<input type="submit" value="Sumbit, or else...">
</form>