#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    5
    Rep Power
    0

    Keep Error 500, again URGENT


    I have written this SIMPLE code:
    #!/usr/bin/python2

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

    print """
    <html>
    <head><title> Dette m virke</title></head>
    <body>
    <h1>Please se dette da . pleeeeeeeeaseeeeeeeee</h1>
    </body>
    </html>
    """

    And i have put the chmod 755 on the file and still get no result. What is wrong.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    34
    Put
    Code:
    import cgi
    import cgitb; cgitb.enable()
    At the top of the script.
    Also, run it from the command line, if there are any syntax errors, that will find them.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    Two other common problems to check for:

    1) the python program is not where the #! at the start of the script says it is. In the code that you post, the python executable is "python2" - is the 2 supposed to be there?

    2) editing the python script on a Windows system, then running it on UNIX without stripping out the carriage returns.

    Both of these will cause the server to barf before the script is executed, so it will not make any difference what is in the script.

    If you can, check the server error logs. This will give you more information about what went wrong.

    Dave - The Developers' Coach
    Last edited by DevCoach; May 12th, 2004 at 02:50 AM.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Location
    South Africa
    Posts
    9
    Rep Power
    0
    Your problem might be the character.
    This causes the following error on my system:
    Code:
    sys:1: DeprecationWarning: Non-ASCII character '\xc3' in file ./test.py on line 8, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
    This may just as well cause the 500 error.
    Try adding this line under the #! line
    Code:
    #!/usr/bin/python2
    # -*- Encoding: latin-1 -*-
    You can exchange latin-1 with utf-8 depending on the program you are using to edit the file and the encoding it uses.

IMN logo majestic logo threadwatch logo seochat tools logo