Friday, 15 July 2011

How to correctly set mime-type for Chromium in Django -


After

In Django, I am serving a PNG image on the fly as:

  matplotlib From .pyplot import figure fig_ATF = figure (figsize = (5, 5), facecolor = 'white') .... response = HttpResponse (content_type = 'image / png') fig_ATF.savefig (feedback, format = 'png' ) Fig_ATF.clear () response ['content-length'] = lane (response.content) return response  

Firefox correctly content type Image / png . Chromium, however, does not display the image and complains: is interpreted as the resource image but mime type text / html

  Cache-Control: Maximum-age = 0 connection: close Content-Encoding: gzip Content-Length: 20 Content-Type: Text / Html; Charset = utf-8 Date: Tuesday, 17 March 2015 10:08:36 GMT Expiration: Tuesday, 17 March 2015 10:08:37 GMT Last-Modified: Tuesday, 17 March 2015 10:08:37 GMT Share this: Apache Vary: Cookie, Accept-Encoding X-Frame-Option: SAMEORIGIN  

Edit This is fine when directly loading the image in Chromium. . Img src = "/ path / to /;

  $ ('# img_location') HTML ('& lt : The problem is that it is added with AJAX through jQuery Image.png? '+ Date now () +' "width =" 500 "height =" 500 "/>); After the text "itemprop =" text "> 

No comments:

Post a Comment