Mercurial > templog
comparison web/index.py @ 29:048143905092
work on web interface
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 12 Jun 2012 23:27:53 +0800 |
parents | e3e0ed7758f9 |
children | 13fcf497f8b7 |
comparison
equal
deleted
inserted
replaced
28:e3e0ed7758f9 | 29:048143905092 |
---|---|
1 #!/usr/bin/env python2.7 | 1 #!/usr/bin/env python2.7 |
2 | 2 |
3 import binascii | 3 import binascii |
4 import hmac | 4 import hmac |
5 import zlib | |
5 | 6 |
6 import bottle | 7 import bottle |
7 from bottle import route, request | 8 from bottle import route, request |
8 | 9 |
9 import config | 10 import config |
15 mac = request.forms.hmac | 16 mac = request.forms.hmac |
16 | 17 |
17 if hmac.new(config.HMAC_KEY, enc_lines).hexdigest() != mac: | 18 if hmac.new(config.HMAC_KEY, enc_lines).hexdigest() != mac: |
18 raise HTTPError(code = 403, output = "Bad key") | 19 raise HTTPError(code = 403, output = "Bad key") |
19 | 20 |
20 lines = binascii.a2b_base64(enc_lines).split('\n') | 21 lines = zlib.decompress(binascii.a2b_base64(enc_lines)).split('\n') |
21 | 22 |
22 log.parse(lines) | 23 log.parse(lines) |
23 | 24 |
24 return "OK" | 25 return "OK" |
25 | 26 |