comparison web/templog.py @ 194:4fa8cbf31065

working kinda
author Matt Johnston <matt@ucc.asn.au>
date Tue, 11 Feb 2014 23:47:53 +0800
parents 8318d50d766d
children 6dd157a12035
comparison
equal deleted inserted replaced
192:e13146001852 194:4fa8cbf31065
48 response.set_header('Content-Type', 'image/png') 48 response.set_header('Content-Type', 'image/png')
49 start_epoch = time.mktime(start.timetuple()) 49 start_epoch = time.mktime(start.timetuple())
50 return log.graph_png(start_epoch, length_minutes * 60) 50 return log.graph_png(start_epoch, length_minutes * 60)
51 51
52 @route('/set/update', method='post') 52 @route('/set/update', method='post')
53 def update(): 53 def set_update():
54 post_json = json.loads(request.forms.data) 54 post_json = json.loads(request.forms.data)
55 55
56 csrf_blob = post_json['csrf_blob'] 56 csrf_blob = post_json['csrf_blob']
57 57
58 return str(post_json['params']) 58 if not secure.check_csrf_blob(csrf_blob):
59 bottle.response.status = 403
60 return "Bad csrf"
61
62 ret = log.update_params(post_json['params'])
63 if not ret is True:
64 bottle.response.status = 403
65 return ret
66
67 return "Good"
59 68
60 @route('/set') 69 @route('/set')
61 def set(): 70 def set():
62 allowed = ["false", "true"][secure.get_user_hash() in config.ALLOWED_USERS] 71 allowed = ["false", "true"][secure.get_user_hash() in config.ALLOWED_USERS]
63 return bottle.template('set', 72 return bottle.template('set',
137 #bottle.run(port=9999, reloader=True) 146 #bottle.run(port=9999, reloader=True)
138 147
139 if __name__ == '__main__': 148 if __name__ == '__main__':
140 main() 149 main()
141 150
142