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

Finished Toolbox #33

Open
wants to merge 2 commits 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
39 changes: 38 additions & 1 deletion flask_app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
"""
Put your Flask app code here.
"""
"""
from flask import Flask
from flask import render_template
from flask import request

app = Flask(__name__)

#@app.route('/')
#def hello_world():
# return render_template('form.html')

def valid_login(name, age):
valid_name = 'william'
valid_age = '18'
if name == valid_name and age == valid_age:
return True
return False

def log_the_user_in(name, age):
return render_template('success.html', name=name, age=age, ninja='Patrick Huston')

@app.route('/', methods=['GET', 'POST'])
def form():
error = None
if request.method == 'POST':
if valid_login(request.form['name'],
request.form['age']):
return log_the_user_in(request.form['name'],
request.form['age'])
else:
error = 'Invalid username/password'
# the code below is executed if the request method
# was GET or the credentials were invalid
return render_template('form.html', error=error)


if __name__ == '__main__':
app.run()
2 changes: 1 addition & 1 deletion hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@app.route('/')
def hello_world():
return 'Hello World!'
return "I'm Mr. MeeSeeks! Look at me!"

if __name__ == '__main__':
app.run()
16 changes: 16 additions & 0 deletions multipage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from flask import Flask
from flask import render_template
app = Flask(__name__)

@app.route('/')
def index():
return 'Index Page'


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

if __name__ == '__main__':
app.run()
27 changes: 27 additions & 0 deletions templates/form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<html>
<head>
<title>
Html Form
</title>
</head>
<body>
<h2>Login Form</h2>
{% if error %}
<p>{{ error }}</p>
{% else %}
<p>Welcome to the Site!</p>
{% endif %}
<form action="/" method="post">
<fieldset>
<legend>Personal information Verification</legend>
Name:<br>
<input type="text" name="name" value="Enter Name" onFocus="this.value='';"><br>
Age:<br>
<input type="text" name="age" value="Enter Age" onFocus="this.value='';"><br>
Favorite SoftDes Ninja:<br>
<input type="text" name="ninja" value="Enter Ninja" onFocus="this.value='';"><br>
<input type="submit" value="Finish">
</fieldset>
</form>
</body>
</html>
7 changes: 7 additions & 0 deletions templates/hello.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!DOCTYPE html>
<title>Hello from Flask</title>
{% if name %}
<h1>Hello {{ name }}!</h1>
{% else %}
<h1>Hello World!</h1>
{% endif %}
12 changes: 12 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>
A Small Hello
</title>
</head>
<body>
<h1>Hi</h1>
<p>This is very minimal "hello world" HTML document.</p>
</body>
</html>
13 changes: 13 additions & 0 deletions templates/success.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<html>
<head>
<title>
{{ name }}'s Account!
</title>
</head>
<body>
<h2>Welcome {{ name }}!</h2>
<p> Your age ({{ age }}) and favorite Ninja ({{ ninja }}) are sensitive pieces of information information. <br> <br>
<b><i> But sensitive information is always safe in <a href="http://thecircle.movie/" target="_blank">the circle</a>. </i></b>
</p>
</body>
</html>