summaryrefslogtreecommitdiff
path: root/bin/web_api.py
diff options
context:
space:
mode:
Diffstat (limited to 'bin/web_api.py')
-rwxr-xr-xbin/web_api.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/bin/web_api.py b/bin/web_api.py
index d221838..1804b30 100755
--- a/bin/web_api.py
+++ b/bin/web_api.py
@@ -51,7 +51,7 @@ class WebAPIServer(http.HTTPServer):
@staticmethod
@web.middleware
- async def validate_auth(req: http.Request, handler):
+ async def validate_auth(req: web.Request, handler):
def get_token() -> str:
name = 'X-Token'
if name in req.headers:
@@ -70,13 +70,13 @@ class WebAPIServer(http.HTTPServer):
return await handler(req)
@staticmethod
- async def get_index(req: http.Request):
+ async def get_index(req: web.Request):
message = "nothing here, keep lurking"
if is_development_mode():
message += ' (dev mode)'
- return http.Response(text=message, content_type='text/plain')
+ return web.Response(text=message, content_type='text/plain')
- async def GET_sensors_data(self, req: http.Request):
+ async def GET_sensors_data(self, req: web.Request):
try:
hours = int(req.query['hours'])
if hours < 1 or hours > 24:
@@ -93,7 +93,7 @@ class WebAPIServer(http.HTTPServer):
data = db.get_temperature_recordings(sensor, (dt_from, dt_to))
return self.ok(data)
- async def GET_sound_sensors_hits(self, req: http.Request):
+ async def GET_sound_sensors_hits(self, req: web.Request):
location = SoundSensorLocation(int(req.query['location']))
after = int(req.query['after'])
@@ -112,7 +112,7 @@ class WebAPIServer(http.HTTPServer):
data = BotsDatabase().get_sound_hits(location, **kwargs)
return self.ok(data)
- async def POST_sound_sensors_hits(self, req: http.Request):
+ async def POST_sound_sensors_hits(self, req: web.Request):
hits = []
data = await req.post()
for hit, count in json.loads(data['hits']):
@@ -125,7 +125,7 @@ class WebAPIServer(http.HTTPServer):
BotsDatabase().add_sound_hits(hits, datetime.now())
return self.ok()
- async def POST_openwrt_log(self, req: http.Request):
+ async def POST_openwrt_log(self, req: web.Request):
data = await req.post()
try:
@@ -154,7 +154,7 @@ class WebAPIServer(http.HTTPServer):
BotsDatabase().add_openwrt_logs(lines, ap)
return self.ok()
- async def GET_recordings_list(self, req: http.Request):
+ async def GET_recordings_list(self, req: web.Request):
data = await req.post()
try:
@@ -176,7 +176,7 @@ class WebAPIServer(http.HTTPServer):
return self.ok(files)
@staticmethod
- def _get_inverter_from_to(req: http.Request):
+ def _get_inverter_from_to(req: web.Request):
s_from = req.query['from']
s_to = req.query['to']
@@ -189,12 +189,12 @@ class WebAPIServer(http.HTTPServer):
return dt_from, dt_to
- async def GET_consumed_energy(self, req: http.Request):
+ async def GET_consumed_energy(self, req: web.Request):
dt_from, dt_to = self._get_inverter_from_to(req)
wh = InverterDatabase().get_consumed_energy(dt_from, dt_to)
return self.ok(wh)
- async def GET_grid_consumed_energy(self, req: http.Request):
+ async def GET_grid_consumed_energy(self, req: web.Request):
dt_from, dt_to = self._get_inverter_from_to(req)
wh = InverterDatabase().get_grid_consumed_energy(dt_from, dt_to)
return self.ok(wh)