[mapserver-users] problem running python mapscript

Mukesh Subedee msubedee at yahoo.com
Tue Aug 9 15:35:19 EDT 2011


Hi all,
 
I've successfully build and install Python MapScript (I get some warnings while building but I don't get any errors). I am trying to run a simple application testing Python MapScript given in Bill Kropla's book. I am able to execute my pytest.py script in command line and can see the generated image in /tmp directory but while I tried using browser (IE 8) to execute it, it just prints my code and doesn't generate image in /tmp directory as well. I don't think I need to make any configuration changes in CGI for execution of the script. Does anyone has idea about the problem?
 
Here is my pytest.py and hello.map file. 
 
#!/usr/bin/python
import cgi
import mapscript
import random

image_name = "helloworld.png"
map = mapscript.mapObj (/home/public_html/map_server/pytest.map)
img=map.draw()
img.save("/home/public_html/map_server/tmp/" + image_name)
print "Content-type: text/html"
print
print "<html>"
print "<header><title>Python Mapscript Test</title></header>"
print "<body>"
print """
<form name="hello" action="pytest.py" method="POST">
<input type="image" name="img" src="/tmp/%s">
</form>
""" % image_name
print "</body>"
print "</html>"
 
my hello.map is:
 
MAP
        NAME "hello_world"
        SIZE 400 300
        EXTENT -1.00 -1.00 1.00 1.00
        IMAGECOLOR 180 180 250
        IMAGETYPE PNG
        WEB
                TEMPLATE "/home/public_html/pytest.py"
                IMAGEPATH "/home/public_html/map_server/tmp/"
                IMAGEURL "/tmp/"
        END
        LAYER
                TYPE point
                STATUS DEFAULT
                FEATURE
                        POINTS 0.0 0.0 END
                        TEXT "Hello World"
                END
                CLASS
                        STYLE
                                COLOR 255 0 0
                        END
                        LABEL
                                TYPE bitmap
                        END
                END
        END
END
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20110809/e2e6dd6e/attachment.html


More information about the mapserver-users mailing list