It's no longer Shrink on web and just getting Python to work on web. Changing to Python 2.7 worked straight away. I assume the problem is the same one I had when trying to run Shrink from the desktop using Python 3.5. So all the samples I found are Python 2. The problem with Python 3.x is the change of syntax for the print command.
When I say worked straight away it gave a web page response in plain text and displayed the html code. I had to eliminate certain lines to get it to work as formatted HTML. It is all trial and error.
So even tho it is not in your current scope, I found it a challenge to make it work as CGI with IIS 7 on Windows 2008 server. I am providing what I learned as documentation in case I or you ever decide to use python on web.
One small syntax error and it gives
"502 - Web server received an invalid response while acting as a gateway or proxy server."
I'm sure there must be a way to give an intelligent syntax error response and indicate the line in error. The lines for cgi and cgitb don't seem to do anything.
Here is the link to the web page.
This page has two methods for running a script.
A Form with submit of fields and an anchor tag which does not pass fields.
Here is the working script.
- Code: Select all
# these import lines don't seem to make any difference
import cgitb; cgitb.enable() # for troubleshooting
# if I omit this first print blank line it fails.
# commenting the following lines made it work as html output
#print 'Status: 200 OK'
#print 'Content-type: text/html'
print '<HTML><HEAD><TITLE>Python Sample CGI</TITLE>'
# I added this line. If I omit it - it still works
print '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">'
print '<H1>Mick Godwin Condensing Cloud Model</H1>'
print '<p>' #this is a comment
print 'At this stage, it is just a working infastructure and more can be done.'