File tree Expand file tree Collapse file tree
assignments/week04/lab/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import os
66import datetime
77
8+
89print "Content-Type: text/html"
910print
1011
1112body = """<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>
1917The 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>
2321Your hostname is %s. <br>
2422<br>
23+ You are coming from %s:%s.<br>
24+ <br>
2525The currenly executing script is %s<br>
2626<br>
2727The 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
4241print body ,
Original file line number Diff line number Diff line change 33
44body = """<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>
1210The 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>
2018The request arrived at %s<br>
2119
22-
2320</body>
2421</html>"""
2522
2623def 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
You can’t perform that action at this time.
0 commit comments