[nSLUG] Python and HTML

Hatem Nassrat hnassrat at gmail.com
Fri Jan 9 16:57:19 AST 2015


On Fri Jan 09 2015 at 1:34:27 PM Frank Geitzler <
frank.geitzler at ns.sympatico.ca> wrote:
>
> 'localhost:8080/cgi-bin/generate_list.py', but unfortunately, when I
> click on the the highlighted text for the next step, (captioned 'timing
> data'...), a pop-up message box captioned 'Opening generate_list.py' and
> stating 'You have chosen to open generate_list.py which is a: Python script
> from localhost:8080".  *What should Firefox do with this file? [...]*
>

So there is a small disconnect here. What you are running is a HTTP
webserver serving a CGI handler, not serving python cgi scripts. The link
you clicked on might work if you had something like apache running, or even
a different kind of python server (more traditional one) that executes cgi
files. I believe this is the part you are hungup on.


The default option shown in a drop-down list is Open with gedit(default),
> and the other option in the drop-down (Other) produces a list of
> applications (which does not include 'Python3').
>

The reason firefox is doing that is because you are now about to download a
file. If you run it with Python, what that will do is execute the file
locally not "on the web" which is not what you want.


> Starting simple_httpd on port: 8080
>
localhost - - [09/Jan/2015 13:13:23] "GET /cgi-bin/generate_list.py
> HTTP/1.1" 200 -
>
Traceback (most recent call last):
>   File "/usr/lib/python3.1/http/server.py", line 1058, in run_cgi
>     os.execve(scriptfile, args, os.environ)
> OSError: [Errno 2] No such file or directory
> localhost - - [09/Jan/2015 13:13:23] CGI script exit status 0x7f00
>

This exception is a little confusing to me, it looks like it is trying to
execute a file but it cannot find it. So I might be wrong about what I
mentioned earlier. Your server might actually be a full blown cgi server
that executes python scripts.

To debug it, you make a backup of /usr/lib/python3.1/http/server.py and
edit it to print the variable "scriptfile" or you can use a debugger. See
what script file is and why this exception is happening.

Also since I cannot see any of this it is really hard to help you debug it.
If you are comfortable, putting this into a quick repo on github would help
others help you debug what is going on.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nslug.ns.ca/pipermail/nslug/attachments/20150109/4cb8dffa/attachment.html>


More information about the nSLUG mailing list