Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This is my MP5 completed! #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
26 changes: 24 additions & 2 deletions flask_app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
"""
Put your Flask app code here.
"""
This is my flask code that makes my website, the "result page", and the "not enough information page"
"""
from flask import Flask
from flask import render_template
from flask import request
app = Flask(__name__)

@app.route('/', methods = ['POST', 'GET'])
def hello_world():
return render_template('index.html')

@app.route('/result', methods = ['POST'])
def result():
error = None
if request.method == 'POST':
if request.form["Name"] and request.form["Age"] and request.form["Who is your favorite SoftDes Ninja"]:
error = None
return render_template("result.html", Name = request.form["Name"], Age = request.form["Age"])
else:
error = 'Please Fill In Fields'
return render_template('neip.html')

if __name__ == '__main__':
app.run()
13 changes: 12 additions & 1 deletion hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,22 @@
"""

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')
# return 'This is my Index Page: hi from sam'

# @app.route('/hello')
# def hello():
# return 'Hello World'

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

if __name__ == '__main__':
app.run()
20 changes: 20 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<title>
Sam's Website
</title>
</head>
<body>
<h1>Hello Visitor!</h1>
<p>Please input all information when prompted below...</p>

<form action = "/result" method = "post">
<p>Name <input type = "text" name = "Name" /></p>
<p>Age <input type = "text" name = "Age" /></p>
<p>SoftDes_Ninja <input type = "text" name = "Who is your favorite SoftDes Ninja" /></p>
<p><input type = "submit" value = "submit" /></p>
</form>

</body>
</html>
15 changes: 15 additions & 0 deletions templates/neip.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<html>
<head>
<title>
Not Enough Info Page
</title>
</head>
<body>
<p>Whoops, not all information was submitted! Please click the "Go Back" button to return to our home page and try again!</p>

<form action = '/' method = "post">
<p><input type = "submit" value = "Go Back" /></p>
</form>

</body>
</html>
14 changes: 14 additions & 0 deletions templates/result.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<table border = 1>

<p> {{ Name}} </p>
<p> {{ Age }} </p>
<p> Patrick Huston </p>

</body>
</html>