diff web/templog.py @ 445:5b9dc87c988f

update web to handle new style params
author Matt Johnston <matt@ucc.asn.au>
date Wed, 05 Dec 2012 22:44:13 +0800
parents 1854abee5a59
children e731c0d30b09
line wrap: on
line diff
--- a/web/templog.py	Thu Nov 29 23:50:40 2012 +0800
+++ b/web/templog.py	Wed Dec 05 22:44:13 2012 +0800
@@ -1,6 +1,7 @@
 #!/usr/bin/env python2.7
 
 import binascii
+import json
 import hmac
 import zlib
 from datetime import datetime, timedelta
@@ -19,15 +20,17 @@
 
 @route('/update', method='post')
 def update():
-    enc_lines = request.forms.lines
+    js_enc = request.forms.data
     mac = request.forms.hmac
 
-    if hmac.new(config.HMAC_KEY, enc_lines).hexdigest() != mac:
+    if hmac.new(config.HMAC_KEY, js_enc).hexdigest() != mac:
         raise bottle.HTTPError(code = 403, output = "Bad key")
 
-    lines = zlib.decompress(binascii.a2b_base64(enc_lines)).split('\n')
+    js = zlib.decompress(binascii.a2b_base64(js_enc))
 
-    log.parse(lines)
+    params = json.loads(js)
+
+    log.parse(params)
 
     return "OK"