Skip to content

Commit bc76e85

Browse files
committed
fix up templates for lab to ensure that they work smoothly and contain no traps
1 parent 0415ac0 commit bc76e85

2 files changed

Lines changed: 23 additions & 27 deletions

File tree

assignments/week04/lab/src/lab1_cgi_template.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,37 @@
55
import os
66
import datetime
77

8+
89
print "Content-Type: text/html"
910
print
1011

1112
body = """<html>
1213
<head>
13-
<title>Lab A - CGI experiments</title>
14+
<title>Lab 1 - CGI experiments</title>
1415
</head>
1516
<body>
16-
17-
The server IP address is %s:%s.<br>
18-
<br>
1917
The server name is %s. (if an IP address, then a DNS problem) <br>
2018
<br>
21-
You are coming from %s:%s.<br>
19+
The server address is %s:%s.<br>
2220
<br>
2321
Your hostname is %s. <br>
2422
<br>
23+
You are coming from %s:%s.<br>
24+
<br>
2525
The currenly executing script is %s<br>
2626
<br>
2727
The request arrived at %s<br>
2828
29-
3029
</body>
3130
</html>""" % (
32-
os.environ['SERVER_ADDR'], # server IP
31+
os.environ['SERVER_NAME'], # Server Hostname
32+
'aaaa', # server IP
3333
'bbbb', # server port
34-
'cccc', # client IP
35-
'dddd', # client port
36-
'eeee', # client hostname
37-
'ffff', # server hostname
38-
'gggg', # this script name
39-
'hhhh', # time
34+
'cccc', # client hostname
35+
'dddd', # client IP
36+
'eeee', # client port
37+
'ffff', # this script name
38+
'gggg', # time
4039
)
4140

4241
print body,

assignments/week04/lab/src/lab2_wsgi_template.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,32 @@
33

44
body = """<html>
55
<head>
6-
<title>Lab A - CGI experiments</title>
6+
<title>Lab 2 - WSGI experiments</title>
77
</head>
88
<body>
99
10-
The server address is %s.<br>
11-
<br>
1210
The server name is %s. (if an IP address, then a DNS problem) <br>
1311
<br>
14-
You are coming from %s:%s.<br>
12+
The server address is %s:%s.<br>
1513
<br>
16-
Your hostname is %s. <br>
14+
You are coming from %s:%s.<br>
1715
<br>
18-
The currenly executing script is %s<br>
16+
The URI we are serving is %s.<br>
1917
<br>
2018
The request arrived at %s<br>
2119
22-
2320
</body>
2421
</html>"""
2522

2623
def application(environ, start_response):
2724
response_body = body % (
28-
environ['HTTP_HOST'], # server IP
29-
'bbbb', # client IP
30-
'cccc', # client port
31-
'dddd', # client hostname
32-
'eeee', # server hostname
33-
'ffff', # this script name
34-
'gggg', # time
25+
environ.get('SERVER_NAME', 'Unset'), # server name
26+
'aaaa', # server IP
27+
'bbbb', # server port
28+
'cccc', # client IP
29+
'dddd', # client port
30+
'eeee', # this script name
31+
'ffff', # time
3532
)
3633
status = '200 OK'
3734

0 commit comments

Comments
 (0)