Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 237e5fc

Browse files
committed
Ported code from workshop material
0 parents  commit 237e5fc

File tree

11 files changed

+263
-0
lines changed

11 files changed

+263
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
venv*

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: python core/data/catseverywhere.py

core/data/catseverywhere.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import os
2+
from flask import Flask
3+
from flask import render_template
4+
from flask import request, redirect
5+
6+
app = Flask(__name__)
7+
8+
email_addresses = []
9+
10+
@app.route('/')
11+
def hello_world():
12+
return render_template('index.html')
13+
14+
@app.route('/signup.html', methods = ['POST'])
15+
def signup():
16+
email = request.form['email']
17+
email_addresses.append(email)
18+
print(email_addresses)
19+
return redirect('/')
20+
21+
@app.route('/emails.html')
22+
def emails():
23+
return render_template('emails.html', email_addresses = email_addresses)
24+
25+
if __name__ == '__main__':
26+
port = int(os.environ.get('PORT', 5000))
27+
app.run(host='0.0.0.0', port=port)
28+

core/data/templates/emails.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<html>
2+
<head>
3+
<title>Cats Everywhere email addresses</title>
4+
</head>
5+
<body>
6+
<p>Here are all the emails we have collected:</p>
7+
<ul>
8+
{% for email in email_addresses %}
9+
<li>{{ email }}</li>
10+
{% endfor %}
11+
</ul>
12+
<p>THIS IS GONNA ROCK!</p>
13+
</body>
14+
</html>

core/data/templates/index.html

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Cats Everywhere!</title>
6+
7+
<link href='http://fonts.googleapis.com/css?family=Sintony:400,700' rel='stylesheet' type='text/css'>
8+
9+
<style type="text/css">
10+
body
11+
{
12+
background-color:#000;
13+
}
14+
15+
h1
16+
{
17+
font-size:48px;
18+
margin-top:0;
19+
font-family:Arial, sans-serif;
20+
text-shadow:2px 0 15px #292929;
21+
letter-spacing:4px;
22+
text-decoration:none;
23+
color:#DDD;
24+
}
25+
26+
#banner
27+
{
28+
width:500px;
29+
height:200px;
30+
text-align:center;
31+
background-image:url(http://i.imgur.com/MQHYB.jpg);
32+
background-repeat:no-repeat;
33+
border-radius:5px;
34+
margin:90px auto auto;
35+
padding:80px 0;
36+
}
37+
38+
.lead
39+
{
40+
background-color:rgba(255,255,255,0.6);
41+
border-radius:3px;
42+
box-shadow:rgba(0,0,0,0.2) 0 1px 3px;
43+
font-family:Sintony, sans-serif;
44+
}
45+
</style>
46+
47+
</head>
48+
49+
<body>
50+
<div id="banner">
51+
<h1>cats everywhere</h1>
52+
<p class="lead">We're bringing cats to the internet. Free. Cute. Awesome.</p>
53+
<form action="signup.html" method="post">
54+
<input type="text" name="email"></input>
55+
<input type="submit" value="Signup"></input>
56+
</form>
57+
</div>
58+
59+
</body>
60+
</html>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from flask import Flask, render_template
2+
app = Flask(__name__)
3+
4+
@app.route('/')
5+
def hello_world():
6+
return render_template('index.html')
7+
8+
if __name__ == '__main__':
9+
app.run(debug=True)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Cats Everywhere!</title>
6+
7+
<link href='http://fonts.googleapis.com/css?family=Sintony:400,700' rel='stylesheet' type='text/css'>
8+
9+
<style type="text/css">
10+
body
11+
{
12+
background-color:#000;
13+
}
14+
15+
h1
16+
{
17+
font-size:48px;
18+
margin-top:0;
19+
font-family:Arial, sans-serif;
20+
text-shadow:2px 0 15px #292929;
21+
letter-spacing:4px;
22+
text-decoration:none;
23+
color:#DDD;
24+
}
25+
26+
#banner
27+
{
28+
width:500px;
29+
height:200px;
30+
text-align:center;
31+
background-image:url(http://i.imgur.com/MQHYB.jpg);
32+
background-repeat:no-repeat;
33+
border-radius:5px;
34+
margin:90px auto auto;
35+
padding:80px 0;
36+
}
37+
38+
.lead
39+
{
40+
background-color:rgba(255,255,255,0.6);
41+
border-radius:3px;
42+
box-shadow:rgba(0,0,0,0.2) 0 1px 3px;
43+
font-family:Sintony, sans-serif;
44+
}
45+
</style>
46+
47+
</head>
48+
49+
<body>
50+
<div id="banner">
51+
<h1>cats everywhere</h1>
52+
<p class="lead">We're bringing cats to the internet. Free. Cute. Awesome.</p>
53+
</div>
54+
<div id="emailform">
55+
56+
</div>
57+
</body>
58+
</html>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from flask import Flask
2+
from flask import render_template
3+
from flask import request, redirect
4+
5+
app = Flask(__name__)
6+
7+
@app.route('/')
8+
def hello_world():
9+
return render_template('index.html')
10+
11+
@app.route('/signup.html', methods = ['POST'])
12+
def signup():
13+
email = request.form['email']
14+
print("The email address is '" + email + "'")
15+
return redirect('/')
16+
17+
if __name__ == '__main__':
18+
app.run(debug=True)
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Cats Everywhere!</title>
6+
7+
<link href='http://fonts.googleapis.com/css?family=Sintony:400,700' rel='stylesheet' type='text/css'>
8+
9+
<style type="text/css">
10+
body
11+
{
12+
background-color:#000;
13+
}
14+
15+
h1
16+
{
17+
font-size:48px;
18+
margin-top:0;
19+
font-family:Arial, sans-serif;
20+
text-shadow:2px 0 15px #292929;
21+
letter-spacing:4px;
22+
text-decoration:none;
23+
color:#DDD;
24+
}
25+
26+
#banner
27+
{
28+
width:500px;
29+
height:200px;
30+
text-align:center;
31+
background-image:url(http://i.imgur.com/MQHYB.jpg);
32+
background-repeat:no-repeat;
33+
border-radius:5px;
34+
margin:90px auto auto;
35+
padding:80px 0;
36+
}
37+
38+
.lead
39+
{
40+
background-color:rgba(255,255,255,0.6);
41+
border-radius:3px;
42+
box-shadow:rgba(0,0,0,0.2) 0 1px 3px;
43+
font-family:Sintony, sans-serif;
44+
}
45+
</style>
46+
47+
</head>
48+
49+
<body>
50+
<div id="banner">
51+
<h1>cats everywhere</h1>
52+
<p class="lead">We're bringing cats to the internet. Free. Cute. Awesome.</p>
53+
<form action="signup.html" method="post">
54+
<input type="text" name="email"></input>
55+
<input type="submit" value="Signup"></input>
56+
</form>
57+
</div>
58+
59+
</body>
60+
</html>

core/hello-world/catseverywhere.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from flask import Flask
2+
app = Flask(__name__)
3+
4+
@app.route('/')
5+
def hello_world():
6+
return 'Hello World!'
7+
8+
if __name__ == '__main__':
9+
app.run()

requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Flask==0.9
2+
Jinja2==2.6
3+
Werkzeug==0.8.3
4+
argparse==1.2.1
5+
wsgiref==0.1.2

0 commit comments

Comments
 (0)