333
|
1 #!/usr/bin/env python2.7 |
|
2 |
334
|
3 import binascii |
|
4 import hmac |
|
5 |
333
|
6 import bottle |
|
7 from bottle import route, request |
|
8 |
334
|
9 import config |
|
10 import log |
|
11 |
333
|
12 @route('/update', method='post') |
|
13 def update(): |
334
|
14 enc_lines = request.forms.lines |
|
15 mac = request.forms.hmac |
|
16 |
|
17 if hmac.new(config.HMAC_KEY, enc_lines).hexdigest() != mac: |
|
18 raise HTTPError(code = 403, output = "Bad key") |
|
19 |
|
20 lines = binascii.a2b_base64(enc_lines).split('\n') |
|
21 |
|
22 log.parse(lines) |
|
23 |
|
24 return "OK" |
333
|
25 |
|
26 @route('/graph.png') |
|
27 def graph(): |
|
28 pass |
|
29 |
|
30 @route('/') |
|
31 def top(): |
|
32 return bottle.template('top', urlparams=request.query_string) |
|
33 |
|
34 def main(): |
|
35 bottle.debug(True) |
|
36 bottle.run(port=9999, reloader=True) |
|
37 |
|
38 if __name__ == '__main__': |
|
39 main() |
|
40 |
|
41 |