cgimodel: CGI Programming Made Easy with Python
Assume you already have this module:
#!/usr/bin/env python # testmethod.py def Method1(name1,name2,name3): print name1,name2,name3 if __name__ == '__main__': Method1('one','two','three')
Edit the cgidisp.py module, inserting the following method under the class Dispatcher:
def cmd_TestMeth(self,parDict): import testmethod name1 = parDict['name1'] name2 = parDict['name2'] name3 = parDict['name3'] testmethod.Method1(name1,name2,name3)Now it is ready! You can call this on the command line by typing on one line:
cgimodel.py -fun TestMeth -name1 one -name2 two -name3 threeor by URL (all on one line):
cgimodel.py?-fun=TestMeth&name1=one&name2=two&name3=threeor by FORMS:
<FORM METHOD="post" ACTION="/cgi-bin/cgimodel.py"> <INPUT TYPE=hidden name=fun value=TestMeth> <INPUT TYPE=hidden name=name1 value=one> <INPUT TYPE=hidden name=name2 value=two> <INPUT TYPE=hidden name=name3 value=three> <INPUT TYPE=SUBMIT VALUE="Run"> </FORM>It would be much better if you could separate HTML text from CGI modules, so that CGI looks thinner and more readable. You can use the template modules (see Resources) to do this. The template module keeps the text away from the CGI and has a page-paragraph structure. Each CGI call can be associated with a page, and each paragraph can be used to set up the view of your HTML page.
cgimodel can host any number of applications. The redundancy of writing a CGI front end is no longer necessary. Since many applications can be run by a single cgimodel, logging information particular to each application can be done for later analysis to improve server performance, stability of each application, better service, etc. Currently, this can be done with the log information generated by the web server.
With cgimodel.py, cgidisp.py and possibly the template.py modules, you should find writing and testing CGI programs easier.
Christine Gemuend has a degree in computer science. She is interested in parallel computers and database systems, and is working in the area of informatics.
|Using Salt Stack and Vagrant for Drupal Development||May 20, 2013|
|Making Linux and Android Get Along (It's Not as Hard as It Sounds)||May 16, 2013|
|Drupal Is a Framework: Why Everyone Needs to Understand This||May 15, 2013|
|Home, My Backup Data Center||May 13, 2013|
|Non-Linux FOSS: Seashore||May 10, 2013|
|Trying to Tame the Tablet||May 08, 2013|
- Using Salt Stack and Vagrant for Drupal Development
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- New Products
- Validate an E-Mail Address with PHP, the Right Way
- A Topic for Discussion - Open Source Feature-Richness?
- Drupal Is a Framework: Why Everyone Needs to Understand This
- The Pari Package On Linux
- New Products
- New Products
- Home, My Backup Data Center
- This is the easiest tutorial
2 hours 33 min ago
- Ahh, the Koolaid.
8 hours 12 min ago
- git-annex assistant
14 hours 11 min ago
- direct cable connection
14 hours 34 min ago
- Agreed on AirDroid. With my
14 hours 44 min ago
- I just learned this
14 hours 48 min ago
15 hours 18 min ago
- not living upto the mobile revolution
18 hours 10 min ago
- Deceptive Advertising and
18 hours 45 min ago
- Let\'s declare that you have
18 hours 46 min ago
Enter to Win an Adafruit Prototyping Pi Plate Kit for Raspberry Pi
It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Prototyping Pi Plate Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- Next winner announced on 5-21-13!
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.