python html can't show generated image

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

python html can't show generated image

goki
This post was updated on .
I don't know if this is appropriate forum for this post but I need help.

I want use python to manipulate with html. This is examplefrom Kropla book on mapserver. First part of python code successfully create and save image to disc. But i can't see created image in browser. Here is python code:

#!c:\python26\python.exe -u
#!/usr/bin/env python


import cgi
import mapscript
import random
map_path = 'C:\\ms4w\\Apache\\cgi-bin\\MK\\'
map_file = 'Hello.map'
image_name = "pythonms_hello" + str(random.randrange(999999)).zfill(6) + ".png"
image_path = "C:\\ms4w\\tmp\\ms_tmp\\"
image_url = image_path + image_name
map = mapscript.mapObj(map_path + map_file)
img = map.draw()
img.save("C:\\ms4w\\tmp\\ms_tmp\\" + image_name)




print "Content-type: text/html"
#print "Content-type: image/png"
print """

<html>
<header><title>Python Mapscript Hello world</title></header>
<body>

<p>FORM

<form name="hello"  action="\\cgi-bin\\pythonms_hello.cgi" method="post">
    <input type="image" name="img" src="%s" width=400 height=300 border=1/>
</form>

</body>
</html>

""" % image_url




What is wrong?