I'm running a Python program on a server and want to provide a client side interface. I'm using a simple web server (from the O'Reilly Programming Python book).
I can generate HTML pages without problems. However now I want to generate a page which includes some JavaScript to validate user input on the client before returning it to the python application on the server. The problematic part of the python code is:
htmlcode = """
`<head`> ## Heading ##
`<title`>PAROT - Report Options`</title`>
`<script type="text/javascript" src="FormChecks.js"`>
`</script`>
`</head`>
`<body`>
`<form method=POST action="cgiRunQuery.py"`>"""'
When I send this to the server, it complains:
tclogin1 - - [08/Dec/2010 10:55:02] "GET /cgi-bin/FormChecks.js HTTP/1.1" 200 -
Traceback (most recent call last):
File "/usr/lib/python2.6/CGIHTTPServer.py", line 255, in run_cgi
os.execve(scriptfile, args, os.environ)
OSError: [Errno 8] Exec format error
tclogin1 - - [08/Dec/2010 10:55:02] CGI script exit status 0x7f00
It looks as though the python is trying to execute the JavaScript. If I create a static html page containing the generated html code (including JavaScript), it all works fine.