diff --git a/hello.py b/hello.py index 2420ed6..bfeed14 100644 --- a/hello.py +++ b/hello.py @@ -1,13 +1,31 @@ -""" -Simple "Hello, World" application using Flask -""" - -from flask import Flask +from flask import Flask, render_template, request, redirect, url_for app = Flask(__name__) -@app.route('/') -def hello_world(): - return 'Hello World!' +#@ is a decorator; the next part is executed --> app.route('/' hello_world) +@app.route('/') #'/' is the index of a page; tells Flask to run this function +def hello(): #for an incoming requests (GET) + return render_template('index.html') + +@app.route('/login',methods=['POST','GET']) +def login(): + if request.method == 'POST': + name = request.form['Name'] + age = request.form['Age'] + ninja = request.form['Favorite NINJA'] + if name == '' or age == '' or ninja == '': + return render_template('error.html') + return render_template('login.html',name=name,age=age,ninja=ninja) + else: + return render_template('error.html') + +@app.route('/index',methods=['POST','GET']) +def index(): + if request.method == 'POST': + return render_template('index.html') if __name__ == '__main__': - app.run() + app.debug = True + app.run( + host = "127.0.0.1", + port = int("7000") + ) diff --git a/templates/error.html b/templates/error.html new file mode 100644 index 0000000..9550acf --- /dev/null +++ b/templates/error.html @@ -0,0 +1,15 @@ + + +
+Seriously, you couldn't fill in three boxes? Give it another try.
+ + + diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..a566cd2 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,21 @@ + + + +Please fill out the information below. That's it.
+ + + \ No newline at end of file diff --git a/templates/login.html b/templates/login.html new file mode 100644 index 0000000..c331a20 --- /dev/null +++ b/templates/login.html @@ -0,0 +1,13 @@ + + + +Wow, you don't look bad for {{ age }}.
+Yeah, I agree. {{ ninja }} is awesome -- way better than that Patrick Huston kid.
+ +