Mercurial > templog
changeset 336:ba4c4df13487
parse the arguments for start/length
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 12 Jun 2012 23:43:49 +0800 |
parents | 1e22eaf93620 |
children | f575ef538f5d |
files | web/index.py |
diffstat | 1 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/web/index.py Tue Jun 12 23:27:53 2012 +0800 +++ b/web/index.py Tue Jun 12 23:43:49 2012 +0800 @@ -26,7 +26,19 @@ @route('/graph.png') def graph(): - pass + start_secs = int(request.query.start) + # url takes time in hours or days + if 'day' in request.query: + start_day = datetime.strptime(request.query.day, '%Y%m%d') + start = time.mktime(start_day.timetuple()) + length = int(request.query.length) * 3600 * 24 + else: + start_hour = datetime.strptime(request.query.hour, '%Y%m%d%H') + start = time.mktime(start_hour.timetuple()) + length = int(request.query.length) * 3600 + + response.set_header('Content-Type', 'image/png') + return log.graph_png(start, length) @route('/') def top():