I want a view to return image data. so something along the lines of
return HttpResponse(image_data, mimetype=”image/png”)
I know I can do a file.read() to get the image data, but because the image is small (like 1×1 px) I want to just store it as a string object (or whatever object I can copy and paste in my code). This way, I save myself the disk lookup everytime the view is hit.
How do i go about this? I’m sure this is easy, I’m just not sure what terms to use for search.
p.s. I know that one does not normally serve images this way with Django.
Here is a simple example from the django-openid project