我正在開發一個Django應用程序,以各種形式顯示數據,包括表格和條形圖。它使用matplotlib創建條形圖作爲png。然後,它返回使用此代碼是:當我使用內置的Django開發服務器Gunicorn沒有提供png
.
.
.
canvas=FigureCanvas(fig)
response=HttpResponse(mimetype='image/png')
canvas.print_png(response)
return response
,一切工作正常。但是,當我使用:
python manage.py run_gunicorn
一切工作除了條形圖。我看到的不是條形圖而是URL。我是否必須運行nginx才能使用gunicorn來顯示png圖像,或者是否有其他東西丟失?
編輯從捲曲
輸出:
About to connect() to 127.0.0.1 port 8000 (#0)
* Trying 127.0.0.1... connected
* Connected to 127.0.0.1 (127.0.0.1) port 8000 (#0)
> GET /myapps/bar_chart1 HTTP/1.1
> User-Agent: curl/7.21.0 (x86_64-pc-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18
> Host: 127.0.0.1:8000
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: gunicorn/0.12.1
< Date: Mon, 16 May 2011 14:05:00 GMT
< Connection: close
< Transfer-Encoding: chunked
< Content-Type: image/png
<
* Leftovers after chunking. Rewinding 16379 bytes
* Closing connection #0
當你與Gunicorn運行它,當你使用curl下載一個PNG,會發生什麼?如果你可以粘貼輸出:'curl -v http://host.name/path/to/png> my.png',那會很有幫助。已添加輸出 – 2011-05-16 14:04:18
。謝謝。 – ErnieP 2011-05-16 14:12:19