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


python programming





perdito
I've searched the forum and noticed that there are already several not very clearly answered problems like mine. Anybody knows how to make python script to run?

I know that I should put it in cgi-bin dir, but that's not all as it doesn't run.
help!
perdito
I wrote the simplest script:

#!/usr/bin/python

print '''content-type: text/html

hello'''


and made permissions 755 for it

and ...

...it ....

... doesn't work!
perdito
I've been receiving email notices of eventual erase of my hosting service and I realize I can't even use it if I'm stuck in this mystery. That's why doesn't a python script, that runs on simplest servers and lowest versions of python, doesn't run here but it turns an error.

Pls answer if anybody have ever ran any python script ever on frih.org, and pls write that script on forum if you know it, or tell me the name and email of somebody else who might know the same.
perdito
Maybe it is very simple like in case of perl, and four characters that are necessary on frih.org even though they aren't on possibly any other server. LIke " -wT". I've read all alike in python docs and can't figure out that some option would be very necessary to signal. Is it something like that?
perdito
This topic keeps sinking towards the last posted topic in this section of forum and still nobody except me thinks about it. Must I promote python and make it more present in the minds of people who write cgi scripts and would it make me happier when it happens in the future if I succeed? Or would I or the future generations pity my efforts even if I make it true? Or neither of these would affect me but something third would happen. Or nothing would happen at all of it all?
perdito
I must quit this thinking a while, I cried a bit and I'll leave it to chances now. If anything tis clear that I should.
perdito
Good night folks ))
rvec
you know we have a chat and an edit function Cool
djclue917
perdito wrote:
I've searched the forum and noticed that there are already several not very clearly answered problems like mine. Anybody knows how to make python script to run?

I know that I should put it in cgi-bin dir, but that's not all as it doesn't run.
help!


Actually, you don't need to put it in cgi-bin. Just place in somewhere in your public_html folder and access it accordingly. My script doesn't even have the comment for specifying the path to the script interpreter. Aside from your Python script, you need to create a custom .htaccess file in the same folder.

This is the contents of my .htaccess since my "default" script is named index.py:

Code:
DirectoryIndex index.py/index
AddHandler python-program .py
PythonHandler mod_python.publisher
PythonAutoReload On
PythonDebug Off


The DirectoryIndex is specified as index.py/index since the "default" function defined in index.py is index().
perdito
I did put .htaccess and index.py too, and put 755 perm, but still I get error 500. And the same with or without #!/usr/bin/python in 1st line. What besides what I did I missed?
perdito
djclue917 wrote:

The DirectoryIndex is specified as index.py/index since the "default" function defined in index.py is index().


Can you pls post your index.py too, I don't have index() function in mine.
toxictux
this may well be due to the fact that server 3 does not have python. i have come to know after searching through many many posts on the forum.

djclue917: are you using the mod_python settings on Frih.org??
djclue917
toxictux wrote:
this may well be due to the fact that server 3 does not have python. i have come to know after searching through many many posts on the forum.

djclue917: are you using the mod_python settings on Frih.org??


What do you mean by mod_python settings? My web app was actually working fine before the move of my frih.net to Server 3. I believe Server 3 still doesn't have a working Python installation. Can anyone confirm this? I don't have a lot of free time to tinker with Server 3 right now to investigate the matter.
Bondings
Indeed server 3 doesn't have a working python installation as of yet. It's something I forgot to do while setting up the server and nobody noticed it until now.

I'm currently trying to make it work, but mod_python is still giving an error. I'll try to find a solution to it.
pedepy
any news on the matter?
Bondings
Python should be working now on server 3. At least it does on my test page. Very Happy
pedepy
Bondings wrote:
Python should be working now on server 3. At least it does on my test page. Very Happy


im getting a 500 still .. although im not quite sure if I have all the steps right.

I placed an .htaccess file in my root public_html/ folder (or whatever that links to) and a small index.py file with an index() function that returns text.

the .htaccess file is the same the one shown in the thread. it reads:


Code:
DirectoryIndex index.py/index
AddHandler python-program .py
PythonHandler mod_python.publisher
PythonAutoReload On
PythonDebug Off


and the python bits are:

Code:
#!/usr/bin/python


def index():
    print "Hello You"






EDIT: ok so i replaced 'print' with a return statement and now I get the goodness. thanks.
toxictux
Thanks a lot Bondings..

I can confirm that Python is now working on server 3. and No You dont need all complicated .htaccess file configuration. the only thing i noticed is that you need to put your script in cgi-bin directory.


Following works for me.

1. create a file tes.py in public_html/cgi-bin directory
2. put following in a file test.py

Code:

#! /usr/bin/env python

print "Content-type: text/html"
print
print "<html>"
print "<center>Hello, Pythonic World....</center>"
print "</html>"



3. change the permission to 755 and. call the script in the browser and there you have it.
toxictux
By the way...

this should give some idea....

http://toxictux.frih.org/cgi-bin/pythoninfo.py

let the fun begin...... Laughing Very Happy
pedepy
dont you guys have sqlite3 with your python 2.5.1 installation ?

im trying to import it and i get an ImportError ...............
pedepy
ok well it seems there is no sqlite3, no mysqldb, nothing ...
Funny thing is I always assumed sqlite3 was part of the stdlib in python 2.5. Is there a reason you guys ommited it ? Or is that part of the recent issues you guys had getting python up on Server 3 ?


I know this as been asked about and requested several times in the past, but would you guys mind providing us with either sqlite3 or mysqldb so we could interface with the databases in python scripts ?

And while were at it, a few good WSGI gateways for mod_python exist, maybe you could pick a nice and install that as well ? ... Although thats much easier to install 'locally' on one's own home space..

Anyway, I guess I'll try & perfect my php skills while python is still only half usable on frihost.
djclue917
My simple Python-based web app was working fine in Server 2. However, I'm still getting an Internal Server Error in Server 3. I don't have the time to debug the issues or possible problem involved right now. Bondings, can you give us more information about the Python installation, e.g., version and the like? Also, is mod_python installed and configured properly? If so, then what version and what are the supported handlers (publisher, etc.)? Thanks in advance. I really want my site to be up and running again...

EDIT: Is mod_python available yet? It's the one I'm using and not CGI. I don't think I'd be able to migrate my script for use with CGI in the near future... Any news or hints on when mod_python will be available in Server 3?
djclue917
toxictux wrote:
Thanks a lot Bondings..

I can confirm that Python is now working on server 3. and No You dont need all complicated .htaccess file configuration. the only thing i noticed is that you need to put your script in cgi-bin directory.


CGI is slow. Use the Publisher handler of mod_python instead. I really want to use a combination of Publisher and PSP but it seem that the current mod_python installation doesn't support the PSP handler... Or maybe it's an older version that requires some changes to my .htaccess.

Anyway, just replying to say that my Python-based site is up-and-running again. The tricky part was getting the C extension to build since ordinary users like me don't have shell access to the server. Wink
Just to share, since using system, exec, etc. in PHP is disabled, I had to use a Python CGI script which in turn calls a shell script that does the actual build process. I can actually just use a pure Python script but using a shell script has its conveniences.
Related topics
Language
Python books
Hi
how did you learn about html, php or other languages???
Python beginners help!
Visual Basic 6
A Simple Python Dynamic Page
Hey!! These days i dont like to play games in my PC.
Hello Everyone
The best of Holland
PythonChallenge - an Amusing Way to Explore Python
Python -need a getch() / kbhit() equivalent
hello world! :)
Do you like Monty Python?
Reply to topic    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.