Differences between revisions 14 and 16 (spanning 2 versions)
Revision 14 as of 2007-01-10 07:42:58
Size: 2580
Editor: dsl-ap-dynamic-132
Comment:
Revision 16 as of 2007-01-31 07:02:44
Size: 2676
Editor: BTNL-TN-DSL-dynamic-151
Comment:
Deletions are marked like this. Additions are marked like this.
Line 72: Line 72:
There are many frameworks for Python Web Application
TurboGears danjo Zope ModPython Pso Aquarium Cheetah ++++++...
There are many frameworks for Python Web Application<br />
TurboGears <br />danjo <br />Zope <br />ModPython <br />Pso <br />Aquarium <br />Cheetah ++++++...
Line 78: Line 78:
and future technologies.... for Easy Web Development :( Standard Environment for RPC + WSGI
and future technologies.... for Easy Web Development
Line 80: Line 81:
-Vinoth -Vinoth vinoth.3v@gmail.com

CGI Scripts

The [http://www.python.org/doc/current/lib/module-cgi.html cgi module] is at the core of the Python CGI scripts.

Basically, you just need to print out an HTTP header ("Content-type: text/html"), a web page, and handle any forms you may have received.

Getting Apache's permissions just right can be annoying, and is sadly beyond this page's scope.

Sample Code

   1 #!/usr/bin/env python
   2 
   3 import cgi
   4 import cgitb; cgitb.enable()  # for troubleshooting
   5 
   6 print "Content-type: text/html"
   7 print
   8 
   9 print """
  10 <html>
  11 
  12 <head><title>Sample CGI Script</title></head>
  13 
  14 <body>
  15 
  16   <h3> Sample CGI Script </h3>
  17 """
  18 
  19 form = cgi.FieldStorage()
  20 message = form.getvalue("message", "(no message)")
  21 
  22 print """
  23 
  24   <p>Previous message: %s</p>
  25 
  26   <p>form:</p>
  27 
  28   <form method="post" action="index.cgi">
  29     <p>message: <input type="text" name="message"/></p>
  30   </form>
  31 
  32 </body>
  33 
  34 </html>
  35 """ % message

See Also

Discussion

  • We need a good python CGI framework - Sridhar R


Yes....

There are many frameworks for Python Web Application<br /> TurboGears <br />danjo <br />Zope <br />ModPython <br />Pso <br />Aquarium <br />Cheetah ++++++...

But it would be Nice if python provides native support for Session Handling, JSON - like XML-RPC Standard Environment for RPC + WSGI and future technologies.... for Easy Web Development

-Vinoth vinoth.3v@gmail.com

CategoryPythonWebsite CategoryLanguage

CgiScripts (last edited 2014-04-16 06:53:27 by DaleAthanasias)

Unable to edit the page? See the FrontPage for instructions.