2 # -*- coding: UTF-8 -*-
10 cgitb
.enable(display
=0, logdir
="../../logs")
12 # https://docs.python.org/2/library/cgi.html
13 form
= cgi
.FieldStorage()
14 # parse the form data into a dictionary
15 vote
= json
.loads(form
.value
)
17 dir = '/a/www-data/on2votes/' + socket
.gethostname()
18 if not os
.path
.exists(dir):
21 # ips are semi-pii, so we keep this data saved away, and
22 # from time to time, throw away data with too much
23 # duplicate ips, then throw away all the ip data.
24 vote
['ip'] = os
.environ
['REMOTE_ADDR']
25 with
open(dir + '/on2votes.log', 'a') as f
:
29 # not that it matters, but tell the client we are happy.
30 print "Status: 200 OK\n";
34 # with open('../logs/vote.txt', 'r') as f:
36 # print json.loads(line)