Skip to content

Commit 7599678

Browse files
committed
Initial code commit
1 parent c0db61c commit 7599678

15 files changed

+169
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,5 @@ venv.bak/
102102

103103
# mypy
104104
.mypy_cache/
105+
106+
venv/

Procfile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
web: waitress-serve --port=$PORT web:app
2+

requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bottle==0.12.13
2+
waitress==1.1.0

runtime.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python-3.6.5

static/aphrodite.gif

18.5 KB
Loading

static/dionysus.jpg

20.3 KB
Loading

static/grapes.png

2.17 KB
Loading

static/poseidon.jpg

10.8 KB
Loading

views/aphrodite.html

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<html>
2+
<head>
3+
<title>Profile: Aphrodite</title>
4+
</head>
5+
<body bgcolor="yellow">
6+
<center>
7+
<br><br>
8+
<img src="/static/aphrodite.gif" />
9+
<h2>Name: Aphrodite</h2>
10+
<br><br>
11+
Favorite animal: Dove
12+
<br><br>
13+
Favorite color: Red
14+
<br><br>
15+
Hometown: Mount Olympus
16+
</center>
17+
</body>
18+
</html>

views/dionysus.html

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<html>
2+
<head>
3+
<title >Profile: Dionysus</title/>
4+
</head>
5+
<body bgcolor="yellow">
6+
<center>
7+
<br><br>
8+
<img src="/static/dionysus.jpg" />
9+
<h2>Name: Dionysus</h2>
10+
<img src="/static/grapes.png"><br><br>
11+
Hometown: Mount Olympus
12+
<br><br>
13+
Favorite animal: Leopard <br>
14+
<br>
15+
Favorite Color: Wine
16+
</center>
17+
</body>
18+
</html>

views/login.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<html>
2+
<head>
3+
<title>Log In</title>
4+
</head>
5+
<body bgcolor="yellow">
6+
<center>
7+
<br><br>
8+
<h2>Please log in to access Mount Olympus:</h2>
9+
<br><br>
10+
<form name="login" action="/login" method="post">
11+
Username: <input type="text" name="user"><br>
12+
Password: <input type="password" name="pwd"><br><br>
13+
<input type="submit" value="Submit">
14+
</form>
15+
</center>
16+
</body>
17+
</html>

views/login_failed.html

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<html>
2+
<head>
3+
<title>Log In</title>
4+
</head>
5+
<body bgcolor="yellow">
6+
<center>
7+
<br><br>
8+
<h2>Please log in to access Mount Olympus:</h2>
9+
<br><br>
10+
<form name="login" action="/login" method="post">
11+
Username: <input type="text" name="user"><br>
12+
Password: <input type="password" name="pwd"><br><br>
13+
<input type="submit" value="Submit">
14+
</form>
15+
Wrong username or password!
16+
</center>
17+
</body>
18+
</html>

views/poseidon.html

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<html>
2+
<head>
3+
<title >Profile: Poseidon</title>
4+
</head>
5+
<body bgcolor="yellow">
6+
<center>
7+
<br><br>
8+
<img src="/static/poseidon.jpg" />
9+
<h2>Name: Poseidon</h2>
10+
<br><br>
11+
Favorite animal: Dolphin
12+
<br><br>
13+
Favorite color: Blue
14+
<br><br>
15+
Hometown: Sea
16+
</center>
17+
</body>
18+
</html>

views/profiles.html

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<html>
2+
<head>
3+
<title>All Profiles</title>
4+
</head>
5+
<body bgcolor="yellow">
6+
<center>
7+
<br><br>
8+
<h1>All Profiles:</h1>
9+
<br><br>
10+
<h2>
11+
<a href="/profiles/aphrodite">Aphrodite</a>
12+
<br><br>
13+
<a href="/profiles/poseidon">Poseidon</a>
14+
<br><br>
15+
<a href="/profiles/dionysus">Dionysus</a>
16+
</h2>
17+
</center>
18+
</body>
19+
</html>

web.py

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
"""
2+
Mount Olympus web scraping example project for Real Python
3+
4+
https://realpython.com
5+
"""
6+
7+
import bottle
8+
9+
10+
@bottle.route('/')
11+
def root():
12+
return bottle.redirect('/login')
13+
14+
15+
@bottle.route('/login')
16+
def login():
17+
return bottle.template('views/login.html')
18+
19+
20+
@bottle.route('/login', method='POST')
21+
def submit_login():
22+
username = bottle.request.forms.get('user')
23+
password = bottle.request.forms.get('pwd')
24+
if username == 'zeus' and password == 'ThunderDude':
25+
return bottle.redirect('/profiles')
26+
return bottle.template('views/login_failed.html')
27+
28+
29+
@bottle.route('/static/<filepath:path>')
30+
def serve_static(filepath):
31+
return bottle.static_file(filepath, root='static/')
32+
33+
34+
@bottle.route('/profiles')
35+
def profiles():
36+
return bottle.template('views/profiles.html')
37+
38+
39+
@bottle.route('/profiles/aphrodite')
40+
def aphrodite():
41+
return bottle.template('views/aphrodite.html')
42+
43+
44+
@bottle.route('/profiles/poseidon')
45+
def poseidon():
46+
return bottle.template('views/poseidon.html')
47+
48+
49+
@bottle.route('/profiles/dionysus')
50+
def dionysus():
51+
return bottle.template('views/dionysus.html')
52+
53+
54+
app = bottle.default_app()

0 commit comments

Comments
 (0)