- - - - -

Getting Python to work


  • Please log in to reply
7 replies to this topic

#1 anjanesh

anjanesh

    Rather Big Orange

  • Members
  • PipPipPipPip
  • 150 posts

Posted 25 August 2007 - 01:58 AM

Hi

I followed the instructions mentioned here.

I created a .py file and uploaded and set persmissions 755 to it.
I have in my.htaccess file
CODE
Options -Indexes +ExecCGI
AddType application/x-httpd-php5 .php
AddHandler cgi-script .py


But http://domain.com/script.py return 500 Internal Server Error

I got it all working on my PC using mod_python, but I cant seem to get it working on my ASO host.

Looking at the error log I see this :

[Sat Aug 25 03:20:27 2007] [error] [client x.x.x.x] Premature end of script headers: /home/username/public_html/script.py

Any idea why ?

Thanks

Edited by anjanesh, 25 August 2007 - 02:22 AM.


#2 Winfried

Winfried

    Small Orange

  • Members
  • PipPip
  • 43 posts

Posted 09 August 2012 - 05:05 PM

Hello

I'd like to use Python as an alternative to PHP for simple use (still need to save data to SQLite, though), ie. without bothering with a web framework like Django.

The post above dates back to 2007: Does Python now work as CGI on ASO shared servers, or is it really a better idea to use FCGI/WSGI?

Thank you.

#3 Winfried

Winfried

    Small Orange

  • Members
  • PipPip
  • 43 posts

Posted 17 August 2012 - 08:07 AM

With help from support, the basic CGI script works. Note: If you copy/pasted the sample in a Windows editor before uploading the file through FTP, watch out for CRLF line endings.

#4 IBBoard

IBBoard

    Massive Orange

  • Volunteer Moderators
  • PipPipPipPipPipPipPip
  • 4,729 posts

Posted 17 August 2012 - 01:46 PM

The dos2unix command is your friend in that case :) Editing files on Windows will almost always cause you problems when moving them to Linux. Either get a decent editor that lets you set LF as the default line ending, or get SSH access and get into the habit of running dos2unix on your files. Alternatively, some FTP clients will automatically do the conversion for you, but be very careful with that, because it could mess up non-text files (e.g. images or zips that happen to have the same byte, even if it isn't interpreted as text).
The more information you provide, the better answer the community can give.

*** Sign up at ASO  with a 15% discount (coupon: saveme15%) or $5 discount (coupon: saveme$5) ***
(Valid on shared hosting and VPS)

#5 Winfried

Winfried

    Small Orange

  • Members
  • PipPip
  • 43 posts

Posted 20 August 2012 - 10:57 AM

Thanks for the tip. It was especially hard to guess since this was the time I was writing a CGI script (in Python or otherwise), and the ASO cPanel didn't help with the error.

I'll set up a test host at home and validate Python scripts before uploading them to ASO from now on.

#6 IBBoard

IBBoard

    Massive Orange

  • Volunteer Moderators
  • PipPipPipPipPipPipPip
  • 4,729 posts

Posted 20 August 2012 - 01:21 PM

Testing on a non-production server is always recommended. ASO servers are "production" i.e. live servers. If, for example, your script went berserk in an infinite loop, chewing up resources, then it'd affect the performance of all of the other customers on the server. If you're doing it on a Dev machine then you're only affecting yourself.

Test on a testing machine and put it live on a live/production machine :)

Edited by IBBoard, 29 September 2012 - 07:19 AM.
Fix implication that Shared Hosting is non-production!

The more information you provide, the better answer the community can give.

*** Sign up at ASO  with a 15% discount (coupon: saveme15%) or $5 discount (coupon: saveme$5) ***
(Valid on shared hosting and VPS)

#7 Winfried

Winfried

    Small Orange

  • Members
  • PipPip
  • 43 posts

Posted 28 September 2012 - 04:03 PM

Right. I'll set up a Linux test host and play with Python before uploading the result to the ASO account.

#8 ASOAyron

ASOAyron

    ASO Ninja

  • Support
  • 44 posts

Posted 17 March 2013 - 01:42 AM

View PostIBBoard, on 20 August 2012 - 01:21 PM, said:

Test on a testing machine and put it live on a live/production machine :)

This is insanely good advice. At every hosting company I can think of, accounts with misbehaving scripts (aka large memory or CPU usage) will generally get suspended as it's considered resource abuse. You may want to check out something like VirtualBox which will let you install a Linux environment similar to a production one that you can use for all testing purposes. You can even use something like Ubuntu Server which makes setting up LAMP pretty easy (even when the P stands for Python). :) Not only will that give you a chance to test that your script won't go bananas, it will also help make sure your scripts are portable, since even Python occasionally has cross-platform issues.
Ayron
Your Friendly Neighborhood Technical Support Ninja Posted Image

Disclaimer: While I do indeed work for A Small Orange, my posts here do not necessarily represent the views of my employer. As such, my posts here are not official support from A Small Orange. If you need official support, please go to the official support portal.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users