Peter's Blog

Redefining the Impossible

Python CGI on Site5


How to get Python CGI running on a Site5 hosting account:

  • Example code, stored in a file in the ~/www/cgi-bin directory:
       1  #!/usr/bin/python
       2  # CGI test
       3  #
       4  import cgi
       5  import cgitb; cgitb.enable()
       6  
       7  strUser = 'Peter'
       8  
       9  #
      10  # Template of html output
      11  #
      12  strHtml = """Content-Type: text/html\n
      13  
      14  <html>
      15  <head>
      16      <title>
      17          This is so cool
      18      </title>
      19  </head>
      20  <body>
      21  <h1>
      22      Careful with that axe Eugene.
      23  </h1>
      24  Hello %s
      25  </body>
      26  </html>
      27  """ % strUser
    
  • chmod the file 700
    chmod 700 FileName
    

The file name does not need the .py extension as it is running as a straight executable.


Filed under: hosting php python site5

Comments are Closed