Gabriel, don't you remember fighting this through with me a year or two ago? It worked just fine back then, but now the same code doesn't work! Go figure! We've tweaked it to this point:
#!/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() picid = int(form['id'].value) x = int(form['x'].value) pics = {1:'pic1',2:'pic2',3:'pic3',4:'pic4',5:'pic5',6:'pic6'} pic = pics[x] db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) cursor= db.cursor() sql = "select " + pic + " from products where id='" + str(picid) + "';" cursor.execute(sql) content = cursor.fetchall()[0][0].tostring() cursor.close() print '''Content-Type: image/jpeg ''' print print content Your comments are very much appreciated. TIA, V On Wed, Oct 7, 2009 at 9:51 AM, Gabriel Genellina <gagsl-...@yahoo.com.ar>wrote: > En Tue, 06 Oct 2009 17:26:19 -0300, Victor Subervi > <victorsube...@gmail.com> escribió: > > The code in question is generated automatically from another script. I >> took >> your idea of the \r\n\r\n and added triple quoting and now it prints out >> this: >> > > That's still wrong. The output should be: > > - a line containing Content-Type: image/jpeg > - a blank line (no more!) > - the actual image data > > A Content-Type of text/html is just *wrong* for an image... > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list >
-- http://mail.python.org/mailman/listinfo/python-list