Problem Displaying Pics

Victor Subervi victorsubervi at gmail.com
Wed Oct 7 22:24:28 CEST 2009


I did that. In fact, just to make things easier, I wrote out exactly what is
supposed to be rendered, as below:

#!/usr/local/bin/python
import cgitb; cgitb.enable()
import MySQLdb
import cgi
import sys,os
sys.path.append(os.getcwd())
from login import login
user, passwd, db, host = login()
form = cgi.FieldStorage()
db = MySQLdb.connect(host, user, passwd, db)
cursor= db.cursor()
sql = "select pic1 from products where id='1';"
cursor.execute(sql)
content = cursor.fetchall()[0][0].tostring()
cursor.close()
print '''Content-Type: image/jpeg

Content-Encoding: base64
'''
print
print content.encode('base64')

I even changed the "image/jpeg" to "text/html" to see if the image would
print out the binary, and it did, so I'm calling the image correctly, just
not rendering the binary as an image.
V


On Wed, Oct 7, 2009 at 2:47 PM, Gabriel Genellina <gagsl-py2 at yahoo.com.ar>wrote:

> En Wed, 07 Oct 2009 12:00:13 -0300, Victor Subervi
> <victorsubervi at gmail.com> escribió:
>
> > print '''Content-Type: image/jpeg
> >
> > '''
> > print
> > print content
>
> On Wed, Oct 7, 2009 at 9:51 AM, Gabriel Genellina <gagsl-
> py2 at yahoo.com.ar>wrote:
>
> > That's still wrong. The output should be:
> >
> > - a line containing Content-Type: image/jpeg
> > - a blank line (no more!)
>         ^^^^^^^^^^^^^^^^^^^^^^^^^
> > - the actual image data
>
> --
> Gabriel Genellina
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091007/9a9be549/attachment.html>


More information about the Python-list mailing list