add /upload/ api
- used for menu icons in ecovacs home
This commit is contained in:
parent
511fc6f456
commit
ac7dd3d302
2 changed files with 42 additions and 0 deletions
|
|
@ -76,11 +76,13 @@ class ConfServer:
|
||||||
api_v1 = {"prefix": "/v1/", "app": web.Application()} # for /v1/
|
api_v1 = {"prefix": "/v1/", "app": web.Application()} # for /v1/
|
||||||
api_v2 = {"prefix": "/v2/", "app": web.Application()} # for /v2/
|
api_v2 = {"prefix": "/v2/", "app": web.Application()} # for /v2/
|
||||||
portal_api = {"prefix": "/api/", "app": web.Application()} # for /api/
|
portal_api = {"prefix": "/api/", "app": web.Application()} # for /api/
|
||||||
|
upload_api = {"prefix": "/upload/", "app": web.Application()} # for /upload/
|
||||||
|
|
||||||
apis = {
|
apis = {
|
||||||
"api_v1": api_v1,
|
"api_v1": api_v1,
|
||||||
"api_v2": api_v2,
|
"api_v2": api_v2,
|
||||||
"portal_api": portal_api,
|
"portal_api": portal_api,
|
||||||
|
"upload_api": upload_api,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
40
bumper/plugins/bumper_confserver_upload_global.py
Normal file
40
bumper/plugins/bumper_confserver_upload_global.py
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import asyncio
|
||||||
|
from aiohttp import web
|
||||||
|
from bumper import plugins
|
||||||
|
import logging
|
||||||
|
import bumper
|
||||||
|
from bumper.models import *
|
||||||
|
from bumper import plugins
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
import os
|
||||||
|
|
||||||
|
class upload_global(plugins.ConfServerApp):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.name = "upload_global"
|
||||||
|
self.plugin_type = "sub_api"
|
||||||
|
self.sub_api = "upload_api"
|
||||||
|
|
||||||
|
self.routes = [
|
||||||
|
|
||||||
|
web.route("*", "/global/{year}/{month}/{day}/{fileid}", self.handle_upload_global_file, name="upload_global_getFile"),
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
self.get_milli_time = bumper.ConfServer.ConfServer_GeneralFunctions().get_milli_time
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
async def handle_upload_global_file(self, request):
|
||||||
|
try:
|
||||||
|
fileID = request.match_info.get("id", "")
|
||||||
|
|
||||||
|
return web.FileResponse(os.path.join(bumper.data_dir,"web","robotvac_image.jpg"))
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception("{}".format(e))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
plugin = upload_global()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue