Hi;
Okay, here's the code:

#! /usr/bin/python
import cgitb; cgitb.enable()
import MySQLdb
import cgi
import sys,os
sys.path.append(os.getcwd())
from login import login
def pic():
  user, passwd, db, host = login()
  form = cgi.FieldStorage()
  db = MySQLdb.connect(host, user, passwd, db)
  cursor= db.cursor()
  sql = "select pic1 from productsX where ID=1;"
  cursor.execute(sql)
  content = cursor.fetchone()[0]
  cursor.close()
  return content
print 'Content-type: image/jpeg'
print 'Content-Encoding: base64'
print
print pic().encode('base64')
print '</body></html>'

This will print all sorts of crap to the screen. I know it's an image,
because for some reason "occasionally" it once upon a time today printed the
actual image to the screen when I had these lines last:

print 'Content-type: text/plain'
#print 'Content-type: image/jpeg'
print
print pic()
print '</body></html>'

Notice the commented out line was essential, but it doesn't matter any more
because the tempermental python interpreter gods changed their attitude
toward this particular code snippet. Good grief. At any rate, this stupid
code worked fine before the last problem that way-laid me for 2 days, and
now it doesn't want to work again. What gives?
TIA,
Victor
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to