How to Embed PHP in HTML print

NickC reply-to at works.fine.invalid
Sun Jan 24 03:09:24 EST 2010


I am running a Python application under apache web server, executing as a 
cgi script.  Most of the output is print statements that write HTML.

I'd like to embed some PHP code within the HTML.  The PHP is a gallery 
plugin script that talks to the core photo gallery application, written in 
php.

The idea is that my python app can display a random image from a photo 
album, using the photo gallery application's plugin script.

If I do: 'print "<?php ... ?>"', it doesn't work. I imagine because the 
web server never sees it as php code.

Is there a way to do this?

Some possible ideas:
Is there a way I can get python to call functions within a PHP app?
Perhaps write the plugin in a separate script in PHP, and include that 
page within my output so that apache recognises the page inclusion?  How 
to get apache to pay attention to the output so it "wakes up" and does 
some server-side includes?

Many thanks for any help.
-- 
NickC



More information about the Python-list mailing list