comparison 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
comparison
equal deleted inserted replaced
444:c5629d79b4ac 445:5b9dc87c988f
1 #!/usr/bin/env python2.7 1 #!/usr/bin/env python2.7
2 2
3 import binascii 3 import binascii
4 import json
4 import hmac 5 import hmac
5 import zlib 6 import zlib
6 from datetime import datetime, timedelta 7 from datetime import datetime, timedelta
7 import time 8 import time
8 import urllib 9 import urllib
17 DATE_FORMAT = '%Y%m%d-%H.%M' 18 DATE_FORMAT = '%Y%m%d-%H.%M'
18 ZOOM_SCALE = 2.0 19 ZOOM_SCALE = 2.0
19 20
20 @route('/update', method='post') 21 @route('/update', method='post')
21 def update(): 22 def update():
22 enc_lines = request.forms.lines 23 js_enc = request.forms.data
23 mac = request.forms.hmac 24 mac = request.forms.hmac
24 25
25 if hmac.new(config.HMAC_KEY, enc_lines).hexdigest() != mac: 26 if hmac.new(config.HMAC_KEY, js_enc).hexdigest() != mac:
26 raise bottle.HTTPError(code = 403, output = "Bad key") 27 raise bottle.HTTPError(code = 403, output = "Bad key")
27 28
28 lines = zlib.decompress(binascii.a2b_base64(enc_lines)).split('\n') 29 js = zlib.decompress(binascii.a2b_base64(js_enc))
29 30
30 log.parse(lines) 31 params = json.loads(js)
32
33 log.parse(params)
31 34
32 return "OK" 35 return "OK"
33 36
34 @route('/graph.png') 37 @route('/graph.png')
35 def graph(): 38 def graph():