By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,986 Members | 1,551 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,986 IT Pros & Developers. It's quick & easy.

how can i return a image in mod python ?

P: n/a
Hi..
I want to show the pictures with mod python directly.

def showimage(req):
some process...
open /var/www/a.jpg and print

for example if i open:
domain.com/a.py/showimage
It must show me image directly (no redirect or html)

How can i do it ?
I'm sorry for my bad english.
Kind Regards....
Nov 18 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Nov 18, 6:46 am, Abandoned <best...@gmail.comwrote:
Hi..
I want to show the pictures with mod python directly.

def showimage(req):
some process...
open /var/www/a.jpg and print

for example if i open:
domain.com/a.py/showimage
It must show me image directly (no redirect or html)

How can i do it ?
I'm sorry for my bad english.
Kind Regards....
How about:

def showimage(req):
req.content_type="image/jpeg" # Change to you image type
req.sendfile("/path/to/image.jpg")
return apache.OK

HTH

BTW mod_python has its own list :)

--
Arnaud

Nov 18 '07 #2

P: n/a
On Nov 18, 10:27 am, Arnaud Delobelle <arno...@googlemail.comwrote:
On Nov 18, 6:46 am, Abandoned <best...@gmail.comwrote:
Hi..
I want to show the pictures with mod python directly.
def showimage(req):
some process...
open /var/www/a.jpg and print
for example if i open:
domain.com/a.py/showimage
It must show meimagedirectly (no redirect or html)
How can i do it ?
I'm sorry for my bad english.
Kind Regards....

How about:

def showimage(req):
req.content_type="image/jpeg" # Change to youimagetype
req.sendfile("/path/to/image.jpg")
returnapache.OK

HTH

BTW mod_python has its own list :)

--
Arnaud
Thank you but i have a another problem.

def showimage(req):
from PIL import Image
im=Image.open("c:\image-2.jpg")
im.thumbnail((800,600), Image.ANTIALIAS)
req.sendfile(im)

give me some error.
How can i return this image witdhout save ?
Nov 19 '07 #3

P: n/a
On Nov 19, 10:27 am, Abandoned <best...@gmail.comwrote:
[...]
Thank you but i have a another problem.

def showimage(req):
from PIL import Image
im=Image.open("c:\image-2.jpg")
im.thumbnail((800,600), Image.ANTIALIAS)
req.sendfile(im)

give me some error.
How can i return this image witdhout save ?
You can use the cStringIO module (http://docs.python.org/lib/module-
cStringIO.html).

HTH

--
Arnaud

Nov 19 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.