Python on a webserver

Just out of interest I thought I would try out some Python code on a webserver. I am told it is installed on my hosting package and was given a link for an example to try: cpanel and Python
I uploaded the code to the cgi-bin as instructed and also in my website and modified the .htaccess file. After trying different permissions I either had a page not found error or a 500 error.
I altered the permissions via FTP as I did not want to install Putty to alter the program permissions via the command line. To get any Python code to work on the server do you have to alter the permission via the command line?

Does anyone have a link to a useful tutorial I could try.

1 Like

You can usually use a program like WinSCP to alter file permissions.

Though, I highly suggest getting familiar with PuTTy and the command line. If it makes you feel any better, you don’t have to install PuTTy and its just a single self contained .exe.

1 Like

I have WinSCP but I do not know if it is a permission problem or user.

Some posts on the net say you need 644 or 655 and others 755 but nothing I have tried works. For example with the code in the cgi-bin and permissions of 644 and 755 I get a 404 error. Outside the cgi-bin with those permissions and the.htaccess mod I get the 500 error.

I have so much rubbish on my PC now I just wanted to avoid having another program even though it is just a exe file. I can not find anything useful on the web but I suppose I will have to try Putty if I have access.

I have had a look at the problem again and may have sorted it. The cpanel example had #! /usr/bin/python and looking at other examples of code it had #!/usr/bin/python
Removing the space seems to work with a permission of 755

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.