-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnameCGI.cgi
More file actions
executable file
·54 lines (48 loc) · 1.21 KB
/
Copy pathnameCGI.cgi
File metadata and controls
executable file
·54 lines (48 loc) · 1.21 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
#!/usr/bin/python
#import resources
import cgi
import cgitb
import json
from cfstorm import *
def log(message):
file = open("/var/log/apache2/alyson.log","a")
file.write(message)
file.write("\n")
file.close()
#get form variables
form = cgi.FieldStorage()
searchType = form.getvalue('searchType', False)
if searchType:
searchType = cgi.escape(searchType)
race = form.getvalue('race', False)
if race:
race = cgi.escape(race)
cycleName = form.getvalue('cycleName', False)
if cycleName:
cycleName = cgi.escape(cycleName)
firstName = form.getvalue('firstName', '')
if firstName:
firstName = cgi.escape(firstName)
lastName = form.getvalue('lastName', '')
if lastName:
lastName = cgi.escape(lastName)
committee = form.getvalue('committee', False)
if committee:
committee = cgi.escape(committee)
#get report
report = 0
if searchType == 'race':
report = queryByRace(unicode(race), cycleName)
elif searchType == 'candidate':
report = queryByCandidate(firstName, lastName)
elif searchType == 'committee':
report = queryByCommittee(committee)
#begin web content
print 'Content-Type: application/json\n\n'
print
#print contents of report
if report:
print json.dumps(report)
else:
report = 'No results found'
print json.dumps(report)