+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 17
Like Tree2Likes

Thread: How to run Python on X10Hosting

  1. #1
    ah-blabla's Avatar
    ah-blabla is offline x10 Lieutenant ah-blabla is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    375

    How to run Python on X10Hosting

    X10Hosting is one of the few free hosting providers allowing Python. Here you will learn how to run python scripts on your website:

    1: Make sure your python script has the following as the very first line:
    Code:
    #!/usr/bin/env python
    2. Upload the file (ftp), and make sure it is set as executable: (varies depending on software)


    3. Make sure the .htaccess file is set up correctly to allow python to run:
    If you placed the script in the cgi-bin directory the script will run directly, otherwise you need to add the following line to the .htaccess file for the directory:
    Code:
    AddHandler cgi-script .py
    4. Enjoy, the script should run.

    Note: you should test python scripts locally, and only upload them once they are finished, since debugging on the server isn't easy.


    PLEASE NOTE: Python and Perl are not currently (July 2, 2011) enabled on the Free Hosting Servers. You have to have pay to upgrade to at least the Illuminated package. Comparison of Plans.
    Last edited by descalzo; 07-02-2011 at 03:46 PM. Reason: Let visitors know the current configuration.

  2. #2
    ah-blabla's Avatar
    ah-blabla is offline x10 Lieutenant ah-blabla is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    375

    Re: How to run Python on X10Hosting

    For python scripts that are outputting content you will also need to add:
    Code:
    print "Content-type: text/plain\n"
    as the second line, otherwise the script won't send you anything, and you get an error 404.

    (Sorry for second post, but it isn't possible to edit the first one.)
    Last edited by ah-blabla; 10-18-2009 at 12:35 PM.

  3. #3
    chony13 is offline x10Hosting Member chony13 is an unknown quantity at this point
    Join Date
    Aug 2009
    Posts
    1

    Smile Re: How to run Python on X10Hosting

    Quote Originally Posted by ah-blabla View Post
    X10Hosting is one of the few free hosting providers allowing Python. Here you will learn how to run python scripts on your website:

    1: Make sure your python script has the following as the very first line:
    Code:
    #!/usr/bin/env python
    2. Upload the file (ftp), and make sure it is set as executable: (varies depending on software)


    3. Make sure the .htaccess file is set up correctly to allow python to run:
    If you placed the script in the cgi-bin directory the script will run directly, otherwise you need to add the following line to the .htaccess file for the directory:
    Code:
    AddHandler cgi-script .py
    4. Enjoy, the script should run.

    Note: you should test python scripts locally, and only upload them once they are finished, since debugging on the server isn't easy.
    Thanks

  4. #4
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,490

    Re: How to run Python on X10Hosting

    Just a note: most FTP clients aren't using that set-up as shown in the picture, and 755 should be used instead

  5. #5
    gpstrack is offline x10Hosting Member gpstrack is an unknown quantity at this point
    Join Date
    Nov 2009
    Posts
    10

    Re: How to run Python on X10Hosting

    The email is sends to me is giving me an error saying:

    /usr/bin/env: python
    : No such file or directory


    Any ideas?
    Last edited by gpstrack; 11-14-2009 at 05:13 PM.

  6. #6
    zegnhabi's Avatar
    zegnhabi is offline x10Hosting Member zegnhabi is an unknown quantity at this point
    Join Date
    Jul 2009
    Location
    On The Net
    Posts
    42

    Re: How to run Python on X10Hosting

    Oh es que ahi la cagaste no es env: python si no: env python
    Yo Soy SQLero, ¿Y Tú?


  7. #7
    rebolli is offline x10Hosting Member rebolli is an unknown quantity at this point
    Join Date
    Mar 2010
    Posts
    3

    Re: How to run Python on X10Hosting

    I uploaded a file, script1.py, containing:

    Code:
    #!/usr/bin/env python
    
    print "Content-type: text/plain\n"
    print """\
    <html>
    <body>
    <h2>Hello World!</h2>
    </body>
    </html>
    """
    to my public_html directory. I've added the line
    "AddHandler cgi-script .py"
    to .htaccess and set the permissions for the file to 755.

    But when I try to run it it goes like this: http://olli.x10hosting.com/script1.py
    "500 Internal Server Error"

    Anyone who knows what's wrong?
    karimirt47 likes this.

  8. #8
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,267

    Re: How to run Python on X10Hosting

    1. Do not hijack old threads. Start a new one yourself.
    2. The way I do it is:

    Code:
    #!/usr/bin/env python
    
    print("Content-type: text/html")
    print("")
    
    print("<html>")
    print("<body>")
    
    print( "Hi there")
    
    print("</body>")
    print("</html>")
    Last edited by descalzo; 03-01-2010 at 05:56 PM.
    Nothing is always absolutely so.

  9. #9
    durand's Avatar
    durand is offline x10Hosting Member durand is an unknown quantity at this point
    Join Date
    Apr 2009
    Posts
    8

    Re: How to run Python on X10Hosting

    Thanks a lot! I needed the htaccess bit.
    dinomirt96 likes this.

  10. #10
    cheezo's Avatar
    cheezo is offline x10 Sophmore cheezo is an unknown quantity at this point
    Join Date
    May 2010
    Posts
    173

    Re: How to run Python on X10Hosting

    thanks for the tutorial.
    hope no one will upload an exploit to my cpanel :D

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Is it alright?
    By runeps in forum Free Hosting
    Replies: 22
    Last Post: 08-20-2009, 03:01 PM
  2. Create your own free forum using x10Hosting
    By Gigacore in forum Tutorials
    Replies: 46
    Last Post: 12-01-2008, 04:07 PM
  3. Setting Up Joomla with x10hosting - Mini-Guide
    By RedOrb in forum Tutorials
    Replies: 28
    Last Post: 11-05-2008, 05:35 PM
  4. Replies: 2
    Last Post: 01-27-2008, 04:18 PM
  5. Account Suspended
    By tehpwner in forum Free Hosting
    Replies: 7
    Last Post: 10-17-2005, 08:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers