-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.cgi
More file actions
executable file
·62 lines (50 loc) · 1.31 KB
/
index.cgi
File metadata and controls
executable file
·62 lines (50 loc) · 1.31 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/var/www/cgi/occupation-data/env/bin/python3
import csv
CSVFILE = "TS060-2021-1.csv"
with open(CSVFILE, 'r', encoding="utf-8") as file:
reader = csv.DictReader(file)
data = list(reader)
authorities = sorted(set(d["Lower Tier Local Authorities"] for d in data))
print("Content-type: text/html")
print()
print(f"""<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
body {{
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
text-align: center;
}}
</style>
</head>
<body>
<h1>Occupation data from the UK Census 2021</h1>
<p>
<a href="https://github.com/alifeee/occupation-data">more context</a>
</p>
<h2>As Graph</h2>
<form action="/occupation-data/pie.cgi">
<label for="r">Authority</label>
<select id="r" name="r">
<option value="ALL" selected>ALL</option>
{"".join(f"<option value='{a}'>{a}</option>" for a in authorities)}
</select>
<button type="Submit">See graph</button>
</form>
<h2>As List</h2>
<form action="/occupation-data/list.cgi">
<label for="r">Authority</label>
<select id="r" name="r">
<option value="ALL" selected>ALL</option>
{"".join(f"<option value='{a}'>{a}</option>" for a in authorities)}
</select>
<button type="Submit">See entire list</button>
</form>
</body>
</html>
""")