diff --git a/hello.py b/hello.py index 2420ed6..d82f837 100644 --- a/hello.py +++ b/hello.py @@ -3,11 +3,36 @@ """ from flask import Flask +from flask import render_template, request, redirect app = Flask(__name__) +@app.route('/hello/') +@app.route('/hello/') +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//', 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() diff --git a/templates/hello.html b/templates/hello.html new file mode 100644 index 0000000..ef9d892 --- /dev/null +++ b/templates/hello.html @@ -0,0 +1,7 @@ + +Hello from Flask +{% if name %} +

Hello {{ name }}!

+{% else %} +

Hello World

+{% endif %} \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..48f03ca --- /dev/null +++ b/templates/index.html @@ -0,0 +1,12 @@ + + + + + A Small Hello + + + +

H9

+

The best webpage

+ + \ No newline at end of file diff --git a/templates/info.html b/templates/info.html new file mode 100644 index 0000000..7775afe --- /dev/null +++ b/templates/info.html @@ -0,0 +1,9 @@ + +Our intelligence services have gathered the following information: +{% if name and age %} +

Name: {{ name }}ski

+

Age: 1{{ age }}

+

Prefered Ninja: Patrick Hustonski

+{% else %} +

Shit.

+{% endif %} \ No newline at end of file diff --git a/templates/register.html b/templates/register.html new file mode 100644 index 0000000..e5b75a1 --- /dev/null +++ b/templates/register.html @@ -0,0 +1,12 @@ + +Give us your info, or else... + +
+ Name:
+
+ Age:
+
+ Favorite Ninja:
+
+ +
\ No newline at end of file