ASP Response.BinaryWrite in Python

S

Sam Sungshik Kong

Hello!

I'm writing ASP in Python.
I want to return an image stream from my ASP code
so that it will look like
<img src="image.asp">.

The problem is that Response.BinaryWrite only accepts SafeArray of Bytes as
parameter, if I understand it correctly.
How can I do it?

The example will be like this.

Response.Expires = 0
Response.Buffer = True
Response.Clear()
Response.ContentType = "image/gif"

Response.BinaryWrite(get_image()) #the function is below.

Response.End()
----------
def get_image():
f = open(file_name, "rb")
s = f.read()
f.close()
return s

Thanks in advance.

kong
 
P

Peter Hansen

Sam said:
I'm writing ASP in Python.
I want to return an image stream from my ASP code
so that it will look like
<img src="image.asp">.

The problem is that Response.BinaryWrite only accepts SafeArray of Bytes as
parameter, if I understand it correctly.

This sounds a lot more like an ASP question than a Python
one, given that you already know how to read the image
file into a Python string. It looks like you need some
method for converting the string to a SafeArray, whatever
that is, so you should probably consult the API for the
interface you are using, maybe on the Microsoft site...

-Peter
 
M

Mark Hammond

Sam said:
Hello!

I'm writing ASP in Python.
I want to return an image stream from my ASP code
so that it will look like
<img src="image.asp">.

The problem is that Response.BinaryWrite only accepts SafeArray of Bytes as
parameter, if I understand it correctly.

What problem specifically?
How can I do it?

Passing a string *should* work. If not, try passing "buffer(string)"

Mark.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,052
Members
47,656
Latest member
rickwatson

Latest Threads

Top