def get_resource_or_410(request: web.Request) -> Resource: try: resource = get_resource(request) if not get_resource_path( config=get_config(request), match_info=request.match_info, uid=resource.uid ).exists(): raise IOError(f"{resource.uid} does not exist") except IOError: logger.warning( "Attempt to continue upload of removed resource", extra={"file_name" "resource_uid": resource.uid}, ) raise web.HTTPGone(text="") return resource
async def show_image(i): if i is None: return web.HTTPNotFound(body='Not found, image is None', headers={'content-type': 'text/html'}) im_data = i['data'] if im_data == None: return web.HTTPGone(body='This image has been removed', headers={'content-type': 'text/html'}) asyncio.get_event_loop().create_task(add_one_view(i['_id'])) if not 'content-type' in i: return web.Response(text='No content type found') return web.Response(body=im_data, content_type=i['content-type'], headers={'Cache-Control': 'max-age=86400'})
async def view_image(request): im_hash = request.match_info['hex'] if '.' in im_hash: im_hash, _ = im_hash.split('.', 1) i = await db.images.find_one({'_id': im_hash}) if i is None: return web.HTTPNotFound(body='Not found', headers={'content-type': 'text/html'}) im_data = i['data'] if im_data == None: return web.HTTPGone(body='This image has been removed', headers={'content-type': 'text/html'}) return web.Response(body=await load_template('view.html', id=im_hash, pic=i), headers={'content-type': 'text/html'})
async def retrieve(self, request): raise web.HTTPGone()
def non_500_error(request): raise web.HTTPGone()