/
index.py
51 lines (42 loc) · 1.4 KB
/
index.py
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
import sys
sys.path.append('/var/www/python/')
from mod_python import apache
from mod_python import util
from mod_python import psp
import jsontemplate
import jsonutils.json as json
import urllib
def index(req):
req.content_type = "text/html"
req.send_http_header()
return psp.PSP(req, "psp/index.psp")
def view(req):
req.content_type = "text/html"
req.send_http_header()
return psp.PSP(req, "psp/view.psp")
def submit2(req):
req.content_type = "text/html"
req.send_http_header()
return psp.PSP(req, "psp/submit.psp")
def ratesubmit(req):
form = util.FieldStorage(req,keep_blank_values=1)
image_id = form.get("id", None)
new_rating = form.get("rating", None)
params = urllib.urlencode({'imagekey': image_id, 'rating': new_rating})
f = urllib.urlopen("http://imaj.lddi.org:8010/ratesubmit", params)
result = jsontemplate.expand('{rating}', json.read(f.read()))
return result
def commentsubmit(req):
form = util.FieldStorage(req,keep_blank_values=1)
image_id = form.get("imagekey", None)
user = form.get("commentuser", None)
cmt = form.get("comment", None)
params = urllib.urlencode({'imagekey': image_id, 'commentuser': user, 'comment': cmt})
f = urllib.urlopen("http://imaj.lddi.org:8010/commentsubmit", params)
# result = jsontemplate.expand('{complete}', json.read(f.read()))
return f.read()
def alive(req):
req.content_type = "text/plain"
req.send_http_header()
req.write("I'm alive")
return