Commit 7599678 1 parent c0db61c commit 7599678 Copy full SHA for 7599678
File tree 15 files changed +169
-0
lines changed
15 files changed +169
-0
lines changed Original file line number Diff line number Diff line change @@ -102,3 +102,5 @@ venv.bak/
102
102
103
103
# mypy
104
104
.mypy_cache /
105
+
106
+ venv /
Original file line number Diff line number Diff line change
1
+ web : waitress-serve --port=$PORT web:app
2
+
Original file line number Diff line number Diff line change
1
+ bottle == 0.12.13
2
+ waitress == 1.1.0
Original file line number Diff line number Diff line change
1
+ python-3.6.5
Original file line number Diff line number Diff line change
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 >
Original file line number Diff line number Diff line change
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 >
Original file line number Diff line number Diff line change
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 >
Original file line number Diff line number Diff line change
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 >
Original file line number Diff line number Diff line change
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 >
Original file line number Diff line number Diff line change
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 >
Original file line number Diff line number Diff line change
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 ()
You can’t perform that action at this time.
0 commit comments