Problem Displaying Pics

Rami Chowdhury rami.chowdhury at gmail.com
Tue Oct 6 21:24:47 CEST 2009


On Tue, 06 Oct 2009 12:19:56 -0700, Victor Subervi  
<victorsubervi at gmail.com> wrote:

> Hi;
> I have the following archaic code that worked just fine for another  
> site. It
> is called with the following url:
>
> http://13gems.com/stxresort/cart/getpic1.py?id=1&x=1
>
> #!/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]
> print 'Content-Type: text/html'

^^^ I believe this is the problem line. It's telling the browser to expect  
HTML, not an image. Remove this, and the later Content-Type header that's  
being printed ("Content-Type: image/jpeg") should take effect.


-- 
Rami Chowdhury
"Never attribute to malice that which can be attributed to stupidity" --  
Hanlon's Razor
408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)



More information about the Python-list mailing list