1. Computing & Technology

Part 1: Laying the Groundwork with HTML, CGI, and PHP

From , former About.com Guide

8 of 10

PHP Plays Middleman Between Python and the HTML Interface

Now for the PHP script. It reads as follows:

 <?php 
 $results = shell_exec ("./RSSReader.py \"" . $_POST["selection"> . "\"") ; 
 
 
 print " 
 <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"> 
 
 <html> 
 <head> 
 <meta http-equiv=\"Content-Type\" content=\"text/html; 
 charset=utf-8\"> 
 <title>About.com's Python-Powered RSS Reader</title> 
 <link rel=\"stylesheet\" type=\"text/css\" href=\"./base.css\" /> 
 </head> 
 <body bgcolor = \"lightblue\"> 
 <font color = \"black\"> 
 <h4> 
 "; 
 
 print $results; 
 print "</h4> </body> </html>"; 
 ?> 
 
 

Essentially, this merely takes the form data from the web page and patches it through to the Python backend. If you do not understand how this works, see my tutorial on PHP-Javascript-Python as a CGI replacement.

  1. About.com
  2. Computing & Technology
  3. Python
  4. Web Development
  5. RSS Reader in Python - Building an RSS Reader With Python - PHP Between Python and HTML

©2012 About.com. All rights reserved.

A part of The New York Times Company.