diff --git a/flask_app.py b/flask_app.py index b03bdc6..fb0636a 100644 --- a/flask_app.py +++ b/flask_app.py @@ -1,3 +1,29 @@ """ -Put your Flask app code here. -""" \ No newline at end of file +This is a simple profile making web app that utilises Flask. -a web development +program with an importable module for Python. +""" +from flask import Flask, request +from flask import render_template +app = Flask(__name__) + + +@app.route('/') +def main(): + return render_template('get_intel.html') + + +@app.route('/login', methods=['GET', 'POST']) +def make_profile(): + if request.method == 'POST': + firstname = request.form["firstname"] + lastname = request.form["lastname"] + age = request.form["age"] + return render_template('profile.html', firstname=firstname, + lastname=lastname, age=age) + else: + return render_template('get_intel.html') + + +if __name__ == '__main__': + app.debug = True + app.run() diff --git a/hello.py b/hello.py index 2420ed6..99f9c3a 100644 --- a/hello.py +++ b/hello.py @@ -3,11 +3,20 @@ """ 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') + + +@app.route('/hello/') +@app.route('/hello/') +def hello(name=None): + return render_template('hello.html', name=name) + if __name__ == '__main__': app.run() diff --git a/templates/get_intel.html b/templates/get_intel.html new file mode 100644 index 0000000..78d051e --- /dev/null +++ b/templates/get_intel.html @@ -0,0 +1,22 @@ + + + + + Hi + + + +

Tell us a little bit about yourself!

+

This is very minimal profile_building website where we definitely don' + t sell your personal information.

+
+ First name:
+
+ Last name:
+
+ Age:
+
+ +
+ + diff --git a/templates/hello.html b/templates/hello.html new file mode 100644 index 0000000..c291c55 --- /dev/null +++ b/templates/hello.html @@ -0,0 +1,7 @@ + +Hello from Flask +{% if name %} +

Hello {{ name }}!

+{% else %} +

Hello World!

+{% endif %} diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..751c2e4 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,12 @@ + + + + + A Small Hello + + + +

Hi

+

This is very minimal "hello world" HTML document.

+ + diff --git a/templates/profile.html b/templates/profile.html new file mode 100644 index 0000000..97f1ded --- /dev/null +++ b/templates/profile.html @@ -0,0 +1,14 @@ + +Your Profile +

+ Hello there {{firstname}} +

+

+ Welcome to your personal profile. +

+ First Name:{{firstname}}
+ Last Name:{{lastname}}
+ Age: {{age}}
+ Favorite ninja: + Patric Huston +