Example #1
0
    def on_get(self, req, resp):

        id = req.get_param_as_int('id', False)
        latest = req.get_param_as_bool('latest', False)

        if latest or id and id > 0:
            if latest:
                temp = Temp.query.order_by(Temp.id.desc()).first()
            else:
                temp = Temp.query.get(id)

            if not temp:
                resp.status = falcon.HTTP_404
            else:
                resp.body = getter(temp)
        else:
            temp = Temp.query
            resp.body = lister(Temp, temp, req)
Example #2
0
    def on_get(self, req, resp):

        id = req.get_param_as_int('id', False)
        latest = req.get_param_as_bool('latest', False)

        if latest or id and id > 0:
            if latest:
                volt = Volt.query.order_by(Volt.id.desc()).first()
            else:
                volt = Volt.query.get(id)

            if not volt:
                resp.status = falcon.HTTP_404
            else:
                resp.body = getter(volt)
        else:
            volt = Volt.query
            resp.body = lister(Volt, volt, req)
Example #3
0
    def on_get(self, req, resp):

        id = req.get_param_as_int('id', False)
        latest = req.get_param_as_bool('latest', False)

        if latest or id and id > 0:
            if latest:
                hum = Humidity.query.order_by(Humidity.id.desc()).first()
            else:
                hum = Humidity.query.get(id)

            if not hum:
                resp.status = falcon.HTTP_404
            else:
                resp.body = getter(hum)
        else:
            hum = Humidity.query
            resp.body = lister(Humidity, hum, req)