-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvoterView.asp
64 lines (46 loc) · 1.94 KB
/
voterView.asp
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
62
63
64
<%@ Language="VBScript" %>
<!--#include file="inc/settings.asp"--><%
requestParameters = ""
if (request.querystring("method") = "street_addresses") then
requestParameters = "query=" & Server.URLEncode(request.querystring("query"))
elseif (request.querystring("method") = "find_voting_locations") then
requestParameters = "streetNumber=" & Server.URLEncode(request.querystring("streetNumber")) & _
"&streetName=" & Server.URLEncode(request.querystring("streetName"))
elseif (request.querystring("method") = "candidate_list") then
requestParameters = "ward=" & Server.URLEncode(request.querystring("ward")) & _
"&nominationDateFrom=" & voterView_candidateList_nominationDateFrom & _
"&nominationDateTo=" & voterView_candidateList_nominationDateTo
else
response.status = "403 Forbidden"
response.end
end if
Set http = Server.CreateObject("MSXML2.ServerXMLHTTP")
http.Open "GET", _
voterView_baseURL & request.querystring("method") & "?" & requestParameters, _
False, _
voterView_userName, _
voterView_password
http.send
response.contentType = "application/json"
responseJSON = http.responseText
' fallback for addresses with two or more poll numbers'
if (request.querystring("method") = "find_voting_locations") then
applicationKey = "votingLocations:" & request.querystring("ward") & ":" & request.querystring("poll")
if (responseJSON = "" or responseJSON = "[]") then
potentialResponseJSON = Application(applicationKey)
if ((not isnull(potentialResponseJSON)) and potentialResponseJSON <> "") then
' substitute found, cache it'
response.expires = 60
responseJSON = potentialResponseJSON
end if
else
' good result found, cache it'
response.expires = 60
Application(applicationKey) = responseJSON
end if
else
' always cache other responses'
response.expires = 60
end if
response.write responseJSON
%>