Mercurial > code > home > repos > light9
view light9/greplin_cyclone.py @ 1835:a5a8e2eca252
checkpoint show data
Ignore-this: 16524b830d4efb4a8d09ec6b8c0c15bc
author | drewp@bigasterisk.com |
---|---|
date | Sat, 09 Jun 2018 22:16:04 +0000 |
parents | 9937e2e3d17b |
children | 7772cc48e016 |
line wrap: on
line source
import cyclone.web, cyclone.websocket, cyclone.httpclient import greplin.scales.twistedweb, greplin.scales.formats from greplin import scales # Like scales.twistedweb.StatsResource, but modified for cyclone. May # be missing features. class StatsForCyclone(cyclone.web.RequestHandler): def get(self): parts = [] statDict = greplin.scales.twistedweb.util.lookup(scales.getStats(), parts) if statDict is None: self.set_status(404) self.write("Path not found.") return query = self.get_argument('query', default=None) if self.get_argument('format', default=None) == 'json': self.set_header('content-type', 'text/javascript; charset=UTF-8') greplin.scales.formats.jsonFormat(self, statDict, query) elif self.get_argument('format', default=None) == 'prettyjson': self.set_header('content-type', 'text/javascript; charset=UTF-8') greplin.scales.formats.jsonFormat(self, statDict, query, pretty=True) else: greplin.scales.formats.htmlHeader(self, '/' + '/'.join(parts), 'svr', query) greplin.scales.formats.htmlFormat(self, tuple(parts), statDict, query)