luanfrj Posted June 18, 2022 Share Posted June 18, 2022 Hi, since migration to plesk some Python cgi scrips stopped to work. I have to do some extra configuration or Python is disabled? I have the following test script in this address https://luan.heliohost.org/cgi-bin/example.py #!/usr/bin/python print ("Content-type:text/html\r\n\r\n") print ('<html>') print ('<head>') print ('<title>Hello Word - First CGI Program</title>') print ('</head>') print ('<body>') print ('<h2>Hello Word! This is my first CGI program</h2>') print ('</body>') print ('</html>') Regards, Luan Quote Link to comment Share on other sites More sharing options...
Krydos Posted June 19, 2022 Share Posted June 19, 2022 Create an .htaccess file with the contents Options +ExecCGI AddHandler cgi-script .py 1 Quote Link to comment Share on other sites More sharing options...
luanfrj Posted June 19, 2022 Author Share Posted June 19, 2022 8 minutes ago, Krydos said: Create an .htaccess file with the contents Options +ExecCGI AddHandler cgi-script .py Thanks Krydos! I gonna do that Quote Link to comment Share on other sites More sharing options...
murilo Posted June 19, 2022 Share Posted June 19, 2022 Oh, hey! Another brazilian using HelioHost's services! 1 Quote Link to comment Share on other sites More sharing options...
luanfrj Posted June 19, 2022 Author Share Posted June 19, 2022 Hi Krydos, I added the .htaccess file, but Python still not working. In the same dir a Perl CGI script work https://luan.heliohost.org/cgi-bin/teste.pl and even a C one https://luan.heliohost.org/cgi-bin/teste_cgi.cgi 10 hours ago, Krydos said: Create an .htaccess file with the contents Options +ExecCGI AddHandler cgi-script .py Quote Link to comment Share on other sites More sharing options...
wolstech Posted June 19, 2022 Share Posted June 19, 2022 Both of those scripts work for me. I see a hello world message from the first "ola mundo" from the second. Quote Link to comment Share on other sites More sharing options...
luanfrj Posted June 19, 2022 Author Share Posted June 19, 2022 Yes, these scripts work. But the one in python return error 500 https://luan.heliohost.org/cgi-bin/example.py 1 hour ago, wolstech said: Both of those scripts work for me. I see a hello world message from the first "ola mundo" from the second. My .htaccess is like that: Quote #Options +ExecCGI AddHandler cgi-script .cgi .py .pl Quote Link to comment Share on other sites More sharing options...
wolstech Posted June 19, 2022 Share Posted June 19, 2022 (edited) Python on Linux requires unix line endings. Your line endings were in Windows/DOS format. I changed them to unix endings and it works now. If you're editing on Windows, my suggestion is to use an editor like Notepad++. You can author files using Unix endings using Edit->EOL Conversion->Unix in that editor. Edited June 19, 2022 by wolstech Editing on Windows 1 Quote Link to comment Share on other sites More sharing options...
luanfrj Posted June 19, 2022 Author Share Posted June 19, 2022 Thanks a lot wolstech! I didn't state that was the cause. I will convert the eol from \r\n to \n Quote Link to comment Share on other sites More sharing options...
Krydos Posted June 19, 2022 Share Posted June 19, 2022 3 hours ago, wolstech said: my suggestion is to use an editor like Notepad++ I've been using Visual Studio Code a lot lately, and it does Linux line endings well too. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.