WebPython: os.write() and stdout.write() can be used simultaneously

Just make sure to flush the output before you switch between the two.

Here is a sample code in WebPython.

import sys
import os
sys.stdout.write("Content-Typoe: image/png\r\n\r\n");
sys.stdout.flush();
f = open("/home/anoop/Downloads/WebPython-128px.png", "rb");
d = f.read();
n=os.write(sys.stdout.fileno(), d );

Comments

Popular Posts