-
Notifications
You must be signed in to change notification settings - Fork 114
Expand file tree
/
Copy pathcgi_2.py
More file actions
34 lines (27 loc) · 750 Bytes
/
cgi_2.py
File metadata and controls
34 lines (27 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
import cgi
import cgitb
cgitb.enable()
import os
import datetime
default = "No Value Present"
print("Content-Type: text/html")
print("")
body = """<html>
<head>
<title>Lab 1 - CGI experiments</title>
</head>
<body>
<p>Hey there, this page has been generated by {software}, running {script}</p>
<p>Today is {month} {date}, {year}.</p>
<p>This page was requested by IP Address {client_ip}</p>
</body>
</html>""".format(
software=os.environ.get('SERVER_SOFTWARE', default),
script=os.environ.get('SCRIPT_NAME', default),
month=datetime.datetime.now().strftime('%B'),
date=datetime.datetime.now().day,
year=datetime.datetime.now().year,
client_ip=os.environ.get('REMOTE_ADDR', default),
)
print(body)