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:
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.
I am still having some difficulty. I am not exactly sure what the problem is so I will give the code first:
I cannot find any syntax errors and am clueless why this will not work. My file is at http://eznet.frih.net/cgi-bin/pythonTest.cgi . Any help is appriciated as I am at a standstill. When I cannot even get simple functions up and running...well I can't really do much at all....
Thanks in advance!
I've implemented a huge project in python on frihost and I am very thankful to them that they are still hosting ti in free with a quality of service.
Your code has no syntatical error, just make sure your CGI file is having 755 permission. http://deepak.frih.net/cgi-bin/test_python.cgi Remeber to change permission .. because it need to be executed.
Thanks for the interest.
Permissions are set. Checked that first
Odd thing is is that I can get simple things to work like
Just not the function I previously listed (as well as other functions)... Still confused.
Hmmm... odd... and you entered it just like this (copy paste)? I am on server 2 and it is not working for me.... confused... still tryin tho.
Yeah, i copy and paste, moreover I'm also on server II see this --> its running fine http://deepak.frih.net/cgi-bin/test_python.cgi
Ha! I do not know what it is that has changed but it is now working for me. I have not changed my script since it wasnt working. reguardless, I am happy to have it working on here.. thanks for your interest.
Nothing special just few steps.
1. Check Permissions
2. Turn on Debugging, it'll really help if you are getting some error.
thanks alot for the quite little tutorial you have there
i tried it out and here are the result
i've imported time and took <time.ctime()> because i wanted to see if it really whas that simple
i've done manny things in python, both GUI's and consolled programs. but im still at the beginning level (i think), so this is going to be a funny experience.
why the <print 'Content: bla bla'>
what does that do? and can i change that so that the text behaves different?
When you are executing any script via CGI, then HTTP server isnt handling your requests, so you've to tell the Browser that this output must be fetched via HTTP/GET.
No, you cant change its a STANDARD line that tells browser that its http output.
Im very excited about running python programs on this server. Im currently having a lot of problems running cgi python on two paid hosting sites that i use, and im not exactly a python newb. I set up on two of my own computers, but I couldnt get it running on those two sites. Anyway, that IDE thing sounds like a really cool project, can I check it out? im currently trying to write a web game in python.
If you are new to FriHost, I do not think that you will be disappointed in this place on any level. Bondings is THE MAN! I have paid budget host in the past and felt it in the service but FriHost blows the away, hands down - and for free no less!
Yeah sure, Frihost provide excellent service all free. If wish if they could start RoR on their server.
velcrobandits, I PM you IDE link. As i dont have shell access on frishot I couldnt make a chrootjail and permission and excutions via pyIDE is a bit problem right now. But still you can have decent idea if you run basic syntax.
how-what-where is debugging? is this on the server? sounds useful, just got my first mini-script working but bound do have problems later on
@spam: see this http://www.frihost.com/forums/vt-53859.html