def ImageView(request, spot_id, image_id, thumb_width=None, thumb_height=None, constrain=False): try: image = SpotImage(spot_id, request=request) contenttype, img = image.get(image_id, constrain, thumb_width, thumb_height) except SpotException as ex: return HttpResponse(status=ex.status_code) else: response = HttpResponse(img, content_type=contenttype) # Remove some headers that don't vary for images unpatch_vary_headers(response, ['Cookie', 'X-Mobile', 'Accept-Language', 'User-Agent']) return response
def MultiImageView(request, spot_id=None, image_ids=None, thumb_width=None, thumb_height=None, constrain=False): try: image = SpotImage(spot_id, request=request) headers, img = image.get_multi(image_ids, constrain, thumb_width, thumb_height) except SpotException as ex: return HttpResponse(status=ex.status_code) else: response = HttpResponse(img) response['Content-Type'] = headers['Content-Type'] response['Sprite-Offsets'] = headers['Sprite-Offsets'] # Remove some headers that don't vary for images unpatch_vary_headers(response, ['Cookie', 'X-Mobile', 'Accept-Language', 'User-Agent']) return response
def ImageView(request, spot_id, image_id, thumb_width=None, thumb_height=None, constrain=False): try: image = SpotImage(spot_id, request=request) contenttype, img = image.get(image_id, constrain, thumb_width, thumb_height) except SpotException as ex: return HttpResponse(status=ex.status_code) else: response = HttpResponse(img, content_type=contenttype) # Remove some headers that don't vary for images unpatch_vary_headers( response, ['Cookie', 'X-Mobile', 'Accept-Language', 'User-Agent']) return response
def ImageView(request, spot_id, image_id, thumb_width=None, thumb_height=None, constrain=False): # Required settings for the client if not hasattr(settings, 'SS_WEB_SERVER_HOST'): raise(Exception("Required setting missing: SS_WEB_SERVER_HOST")) if not hasattr(settings, 'SS_WEB_OAUTH_KEY'): raise(Exception("Required setting missing: SS_WEB_OAUTH_KEY")) if not hasattr(settings, 'SS_WEB_OAUTH_SECRET'): raise(Exception("Required setting missing: SS_WEB_OAUTH_SECRET")) consumer = oauth2.Consumer(key=settings.SS_WEB_OAUTH_KEY, secret=settings.SS_WEB_OAUTH_SECRET) client = oauth2.Client(consumer) contenttype, img = get_image(client, spot_id, image_id, constrain, thumb_width, thumb_height) response = HttpResponse(img, content_type=contenttype) # Remove some headers that don't vary for images unpatch_vary_headers(response, ['Cookie', 'X-Mobile', 'Accept-Language', 'User-Agent']) return response
def MultiImageView(request, spot_id=None, image_ids=None, thumb_width=None, thumb_height=None, constrain=False): try: image = SpotImage(spot_id, request=request) headers, img = image.get_multi(image_ids, constrain, thumb_width, thumb_height) except SpotException as ex: return HttpResponse(status=ex.status_code) else: response = HttpResponse(img) response['Content-Type'] = headers['Content-Type'] response['Sprite-Offsets'] = headers['Sprite-Offsets'] # Remove some headers that don't vary for images unpatch_vary_headers( response, ['Cookie', 'X-Mobile', 'Accept-Language', 'User-Agent']) return response