FRIHOSTFORUMSSEARCHFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Python via CGI - A personal triumph

 


eznet
Python via CGI on FriHost

I know that the topic has been addressed elsewhere. With this said there seems to be some confusion as most of the addressing of this issue consists of a blend of mod_python and CGI info; something that is deeply confusing for a noob(or at least was for my feeble noob mind). To hopefully help anyone (as dumb as I) who has had problems with this, I have created this brief (and ridiculously elementary) tutorial. I concluded my problems initially were with A)combining mod and cgi info in my attempts or b)sequence and completion of all these steps(or lack there of).

Needless to say, I finally got my Python CGI working. I, of course, cannot take credit for it as I have read many, many articles (onsite and off) tonight. It has been a night of mistakes to say the least. But alas, this has passed and now I have an executable Python CGI script.

I am apparently not yet savvy enough to use the mod_python method. To be quite honest I had a hard enough time with the CGI which is supposed to be really easy; so I will be learning to crawl before I walk.

If you are interested in the step-by-step then here you go…

(note: Everything can be done from within your DirectAdmin file manager from creating the cgi files to editing and permission settings)

Step1: enter a cgi-bin directory of choice (either create a new sub-domain or go into a public directory you already have available).

Step2: Open up your favorite syntax editor (I personally like Crimson) and enter the following:
Code:

#!/usr/bin/python

# Required header that tells the browser how to render the text.
print "Content-Type: text/plain\n\n"

# Print a simple message to the display window.
print "Hello, World!\n"

Save the file to pythonTest.cgi

Step3: Upload pythonTest.cgi to the cgi-bin director that you are working in (Step1).

Step4: Set your permissions for pythonTest.cgi to 755 (executable) – can be done via explorer, your ftp program or DirectAdmin file console.

Step5: Open up Firefox (or your browser of choice) and enter http://yourName.frih.net/yourDirectory/cgi-bin/pythonTest.cgi and press enter! - Of course you will need to replace yourName with your frihost name and also replace yourDirectory with the directory you are working in (Step1).

Step6: Start writing python web-apps (I guess, I ain’t there yet).

In my case, as I think is everyone’s case who is using Python via CGI instead of mod_python, there was no need to have anything within my .htaccess

I have yet to get the hang of mod_python but I hope to as I have read that it is much faster. However, this will be down the road, my python writing is currently nowhere near a level of complexity that will require increase performance.

Hope this helps someone.

Resources:

http://www.cs.virginia.edu/~lab2q/lesson_1/

http://www.frihost.com/forums/vt-43909.html&highlight=modpython

http://www.frihost.com/forums/vt-43006.html&highlight=modpython
Related topics
Python via CGI - A personal triumph
Does frihost still support Python for CGI programming
How to debug Python CGI errors
Python CGI script 500 error
Language
A Simple Python Dynamic Page
mod_python outside cgi-bin
Decent apache and mod_python anyone?
My CG work With Phtotsop 7~
python script???
Python beginners help!
Python
Perl permissions
FIND THE DIFFERENCE!
django on FRIHOST
Python, CGI and CSS
Hello
Python CGI work with FRIHOST
Problem with python cgi - does Python CGI work?
problem with python's os.mkdir in cgi test
What is the difference between CGI and python script?
Play IRC Via Web
Programming links, info, and tutorials
Big guide to FREE programs!
Reply to topic    Frihost Forum Index -> Scripting -> Others

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