diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..136cd22 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: python3 flask_app.py diff --git a/flask_app.py b/flask_app.py new file mode 100644 index 0000000..cd46cae --- /dev/null +++ b/flask_app.py @@ -0,0 +1,49 @@ +""" +Put your Flask app code here. +""" + +from flask import Flask +from flask import render_template +from flask import request +import os +app = Flask(__name__) + + +@app.route('/return', methods=['POST', 'GET']) +def hello_world(): + print('in method') + error = None + if request.method == 'POST': + if(request.form['Name'] != '' and request.form['Age'] != '' and request.form['Favorite Softdes Ninja'] != ''): + name = request.form['Name'] + age = request.form['Name'] + else: + error = 'Input Required' + + # error = 'Invalid username/password' + # if request.method == 'GET': + name = request.form['Name'] + age = request.form['Age'] + print(name) + print(age) + # the code below is executed if the request method + # was GET or the credentials were invalid + return render_template('return.html', name=name, age=age, error=error) + + +@app.route('/ajax', methods=['GET']) +def changeConent(): + print('this was accessed') + return 'This is Ajax Request Respose from the Server. Sent without reloading the page' + + +@app.route('/') +def hello(name=None): + return render_template('index.html',name = name) + + + +if __name__ == '__main__': + HOST = '0.0.0.0' if 'PORT' in os.environ else '127.0.0.1' + PORT = int(os.environ.get('PORT', 5000)) + app.run(host=HOST, port=PORT) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e3e9a71 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +Flask diff --git a/runtime.txt b/runtime.txt new file mode 100644 index 0000000..c91e43b --- /dev/null +++ b/runtime.txt @@ -0,0 +1 @@ +python-3.6.1 diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..d7fc964 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,16 @@ + +Hello from Nick +

Hello !

+ +
+
+ Personal information: + Name:
+
+ Age:
+
+ Favorite SoftDes Ninja:
+

+ +
+
diff --git a/templates/return.html b/templates/return.html new file mode 100644 index 0000000..c843373 --- /dev/null +++ b/templates/return.html @@ -0,0 +1,32 @@ + +Hello from Nick +{% if not error %} +

Hello {{name}}!

+

Age: {{age}}

+

Favorite SoftDes Ninja: Patrick Hutson

+{% else %} +

{{error}}

+{% endif %} + + + +
+

Look how dynamic this page is!

+ +
+ + + +