Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32b7e1e301 | ||
|
|
552c89bec9 |
@@ -348,11 +348,11 @@ if _server is not None:
|
||||
except Exception as e:
|
||||
return web.json_response(dict(error=str(e)), status=500)
|
||||
|
||||
@_server.routes.put("/api/etn/image/{id}")
|
||||
async def put_image(request: web.Request):
|
||||
try:
|
||||
id = request.match_info.get("id", "")
|
||||
if id in image_cache:
|
||||
await request.release() # Consume and discard the data to avoid connection abort
|
||||
return web.json_response(dict(status="cached"), status=200)
|
||||
|
||||
content_type = request.headers.get("Content-Type", "application/octet-stream")
|
||||
@@ -365,6 +365,17 @@ if _server is not None:
|
||||
except Exception as e:
|
||||
return web.json_response(dict(error=str(e)), status=500)
|
||||
|
||||
async def _put_image_expect_handler(request: web.Request):
|
||||
if request.match_info.get("id", "") in image_cache:
|
||||
# Skip "100 Continue" since we don't need the data, return 200 immediately.
|
||||
return web.json_response(dict(status="cached"), status=200)
|
||||
# otherwise run default aiohttp handler
|
||||
return None
|
||||
|
||||
_server.app.router.add_route(
|
||||
"PUT", "/api/etn/image/{id}", put_image, expect_handler=_put_image_expect_handler
|
||||
)
|
||||
|
||||
@_server.routes.put("/api/etn/upload/{folder_name}/{filename}")
|
||||
async def upload(request: web.Request):
|
||||
folder_name = request.match_info.get("folder_name", "")
|
||||
|
||||
Reference in New Issue
Block a user