Mercurial > templog
comparison web/index.py @ 30:13fcf497f8b7
parse the arguments for start/length
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 12 Jun 2012 23:43:49 +0800 |
parents | 048143905092 |
children | 5e75e08d20ac |
comparison
equal
deleted
inserted
replaced
29:048143905092 | 30:13fcf497f8b7 |
---|---|
24 | 24 |
25 return "OK" | 25 return "OK" |
26 | 26 |
27 @route('/graph.png') | 27 @route('/graph.png') |
28 def graph(): | 28 def graph(): |
29 pass | 29 start_secs = int(request.query.start) |
30 # url takes time in hours or days | |
31 if 'day' in request.query: | |
32 start_day = datetime.strptime(request.query.day, '%Y%m%d') | |
33 start = time.mktime(start_day.timetuple()) | |
34 length = int(request.query.length) * 3600 * 24 | |
35 else: | |
36 start_hour = datetime.strptime(request.query.hour, '%Y%m%d%H') | |
37 start = time.mktime(start_hour.timetuple()) | |
38 length = int(request.query.length) * 3600 | |
39 | |
40 response.set_header('Content-Type', 'image/png') | |
41 return log.graph_png(start, length) | |
30 | 42 |
31 @route('/') | 43 @route('/') |
32 def top(): | 44 def top(): |
33 return bottle.template('top', urlparams=request.query_string) | 45 return bottle.template('top', urlparams=request.query_string) |
34 | 46 |