Python CGI

Status
Not open for further replies.

thedaemo

New Member
Messages
3
Reaction score
0
Points
0
I have another account that is a paid package for Premium, and Ive been trying to get python to work, I changed the permissions to 755, added "#!/usr/bin/env" python to the top of the file and "AddHandler cgi-script .py" to the .htaccess file, but when I open it, http://livoniawarriors.com/test.py, I only get the plain text of the file.

Is python still supported? Its a Premium account, so did I do something wrong?

Thanks!
 

hbazer

Member
Messages
398
Reaction score
7
Points
18
While you can post in this forum about your Premium account - you will receive better support at the "Premium" support page - they have full-time staff to help you

This hashbang (first line in script) of [ #!/usr/local/bin/python ] works for me in my "Premium" account

Python is supported in free-hosting and paid service accounts

Here is my 'test' Python script

Code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

print "Content-type: text/plain\r\n"

print "Hello world from Python"
 
Last edited:

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
It's actually more correct to say that Python is occasionally available in Free Hosting. (It has been disabled in the past, and may be disabled in the future. It's one of those areas where so many users get in over their heads that it's often easier to just say "everyone out of the pool!" When it's available, only those modules that are available are available, and folks expect that any old code they find on the web ought to work--despite the fact that it requires binaries that aren't present on the server.)
 

thedaemo

New Member
Messages
3
Reaction score
0
Points
0
This is what I had used, (on the premium server) and the reason i dont go there is because although i have cpanel access Im not quite sure how to actually log into the portal, its a joint account. And is changing the htaccess and permissions still necessary?
Code:
[COLOR=#000000]#!/usr/bin/env python[/COLOR]
print "Content-type: text/plain\n"print """\<html><body><h2>Hello World!</h2></body></html> [COLOR=#000000]"""
[/COLOR]
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
You do have to change the .htaccess to tell the server to interpret Python files, yes, otherwise they will be treated as the default MIME type (text/plain). Oh, and if you want to create a web page from Python, you'll have to change the output content-type to "text/html", otherwise you'll get a screen full of HTML source code.
 

hbazer

Member
Messages
398
Reaction score
7
Points
18
This is what I had used, (on the premium server) and the reason i dont go there is because although i have cpanel access Im not quite sure how to actually log into the portal, its a joint account. And is changing the htaccess and permissions still necessary?
Code:
[COLOR=#000000]#!/usr/bin/env python[/COLOR]
print "Content-type: text/plain\n"print """\<html><body><h2>Hello World!</h2></body></html> [COLOR=#000000]"""
[/COLOR]

Yes - adding to the .htaccess file and setting permissions of the source file IS still necessary

By making the edit from your source code to
Code:
#!/usr/bin/env python

print("Content-type: text/html\n\n")

print("<html><body><h2>Hello World!</h2></body></html>")

runs without error on premium server [ s1 ] and free-hosting server [ Vox ]
 
Status
Not open for further replies.
Top