Beispiel #1
0
    def GET(self):
        log.debug('headers %s', self.req.headers())
        log.debug('get cookie %s' % self.req.cookie)

        with get_connection_exception('test') as db:
            data = db.query('show processlist')

        t = str(time.time())
        log.debug('set cookie time: %s', t)

        self.resp.set_cookie('time', t, expires=int(time.time()) + 20)
        self.write(template.render('index.html', data=data))
Beispiel #2
0
    def ping(self):
        now = datetime.datetime.now()
        retdata = {
            'time': str(now)[:19],
            'dbtime': '',
            'starttime': config.starttime,
            'pid': os.getpid()
        }
        if hasattr(config, 'DATABASE'):
            keys = list(config.DATABASE.keys())

            with get_connection_exception(keys[0]) as conn:
                ret = conn.get("select now()", isdict=False)
                retdata['dbtime'] = str(ret[0])[:19]

        if hasattr(config, 'PORT'):
            retdata['port'] = config.PORT

        retobj = {'respcd': '0000', 'resperr': '', 'data': retdata}

        return json.dumps(retobj)