FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Problem with python cgi - does Python CGI work?





lasdjfk
Forgive a newbie's stupidity. I can't make Python CGI work with FRIHOST!

In public_html/cgi-bin I have 2 files. ".htaccess" and "mptest.py".

In htaccess I have:
Code:

<Directory "/domains/andreas.frih.net/public_html/cgi-bin/">
  AddHandler python-program .py
  PythonHandler mptest
  PythonDebug On
</Directory>


In mptest.py:
Code:
#!/usr/bin/env python
print "Content-type: text/plain\r\n\r\n",
print "Hello world"


Here, the file doesn't work: http://www.andreas.frih.net/cgi-bin/mptest.py.

Quote:
Internal Server Error


What on earth am I doing wrong???

Edit by WuMingsDen:
-renamed- from Problem with python cgi to Problem with python cgi - does Python CGI work?
-moved- from the Scripting [others] Forum to the WebHosting Support Forum
modak
Stupid question, but maybe relevant nevertheless : Is python support installed on the Frihost servers ?

My cPanel doesn't list any entry for Python. Fantastico doesn't list a single Python webapp.

I'm inclined to think that Python web apps are not supported on Frihost. Admins correct me if I am wrong.

Can you please post your Apache error logs somewhere for us to have a look ?
Bondings
modak, at the moment mod_python is only installed on server 2, however I think python should also be working as a cgi on server 1.

Maybe try this instead, without the directory thing.
Code:
AddHandler python-program .py
  PythonHandler mptest
  PythonDebug On
Daniel15
Maybe this post will help you? Smile
lasdjfk
Thanx Bondings! I did as you said with .htaccess.
However now I get the following message:
Quote:
Mod_python error: "PythonHandler mptest"

Traceback (most recent call last):

File "/usr/lib/python2.2/site-packages/mod_python/apache.py", line 185, in Dispatch
object = resolve_object(req, module, object_str, silent)

File "/usr/lib/python2.2/site-packages/mod_python/apache.py", line 394, in resolve_object
raise AttributeError, s

AttributeError: module '/home/lasdjfk/domains/andreas.frih.net/public_html/cgi-bin/mptest.py' contains no 'handler'


I think apache is trying read my .py-file as a mod_python file. But this is not a mod_python file Rolling Eyes . Can I change .htaccess to work with CGI-python or doesn't it work with Server 2 ?
And if it doesn't work with server 2 can Bondings change me to server 1?

Or maybe I should just learn mod_python instead. I heard it's better and more powerful than Python-CGI Cool .

Ciao,
Bondings
Oh but it should be working fine as a cgi. But in that case you don't need to put any of that code in the .htaccess file.
lasdjfk
Bondings wrote:
Oh but it should be working fine as a cgi. But in that case you don't need to put any of that code in the .htaccess file.



Hey! It works now! If I'd knew it was that simple... However it only works in cgi-bin directory, but that's enough for me.
Thanks all,
Daniel15
Glad to see that you solved your problem Smile
I'm going to -close- this topic. If you have any futher problems, please feel free to create a new topic Very Happy
Related topics
SMTP problem
problem with cgi perl script
Does frihost still support Python for CGI programming
Python beginners help!
Python CGI work with FRIHOST
Python via CGI - A personal triumph
Python via CGI - A personal triumph
Is there a Python Hello World using Apache?
Linkrefferal - Does Increase Traffic
Python, CGI and CSS
Drying clothes in the microwave
Python CGI script 500 error
Advice on switching OS [Windows --> UNIX? Linux?]
Tutorial needed for python cgi
This topic is locked: you cannot edit posts or make replies.    Frihost Forum Index -> Support and Web Hosting -> Web Hosting Support

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.