Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't Ocsigen run my python file?

Tags:

ocaml

ocsigen

The configure file test.conf is as below:

<ocsigen>
<server>
<port>*:8000</port>

<logdir>/home/zaxis/tmp/log/</logdir>
<datadir>/home/zaxis/tmp/data</datadir>
<user>zaxis</user>
<group>wheel</group>
<charset>utf-8</charset>
......
<extension findlib-package="ocsigen_ext.cgimod">
  <cgitimeout value="30"/>
</extension>

<extension findlib-package="ocsigen_ext.staticmod"/>
......
<site path="qachina" charset="utf-8">
    <cgi root="cgi-bin" dir="/media/E/www/qachina/cgi-bin"/>
    <static dir="/media/E/www/qachina" />
</site>
....
<commandpipe>/home/zaxis/tmp/ocsigen_command</commandpipe>
</server>
</ocsigen>

Then I run Ocsigen:

ocsigeocsigen -c test.conf

I can visit http://127.0.0.1:8000/qachina/index.htm. However, Ocsigen does not execute my python script in cgi-bin but wants the browser to download it.

BTW, all python script files can be run in the shell directly.

>head cgi-bin/nav.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-enter code here
...

I cannot visit Ocsigen's mailing list, so I'm posting here for suggestions.

like image 685
z_axis Avatar asked Dec 16 '22 07:12

z_axis


1 Answers

What is exactly your Ocsigen version?

I've just tried with ocsigen 1.3.4 (the version currently in Debian testing), and there seems to be a bug (on the Ocsigen side) with your configuration snippet. What you want can be achieved with:

<cgi regexp="cgi-bin/([^/]*)" dir="/usr/lib/cgi-bin/" script="\1" />

I've just checked on all running instances of Ocsigen that I have access to, and they all use the "regexp" attribute. The documentation does allow your version, though, and the server accepts it. One of these two alternatives is a bug.

FYI, running ocsigen with the -V option helped.

like image 95
Stéphane Glondu Avatar answered Jan 12 '23 18:01

Stéphane Glondu