If you are looking for a way to embed Python within HTML you might want to take a look at a web environment called Spyce. Two of its advantages are its features and its flexibility. Keep reading to learn how you can Spyce up your programs.
The idea of “Python Server Pages” is nothing new or unique to one particular web environment. It's an idea that is featured in several environments, including mod_python and Karrigell. However, while mod_python and Karrigell don't completely focus on embedding Python within HTML, a web environment named Spyce does. Spyce allows for Python to be embedded, but it also contains a few more tricks when it comes to embedding, such as active tags. Moreover, the fact that Spyce can be used with several technologies with minimal configuration is a huge advantage. In this article, we'll take a look at how Spyce is configured and what it offers.
Simply download the archive and extract it to a directory that's easily accessible.
Spyce can be installed in numerous ways, which is convenient since you probably won't have to change the face of your existing environment in order to benefit from Spyce. You may choose to run Spyce as its own web server, which can run behind Apache, or you can use FastCGI, mod_python or plain old CGI. Spyce already comes with configuration directives that can be slightly modified and then used with Apache.
To run Spyce as its own web server, open the directory where you extracted spyce and run the file spiceCmd.py with the “-l” flag:
Spyce is configured to run on port 8000 by default. If you wish to have Spyce listen to a different port, open the file spyceconf.py and change the port variable.
The remaining installation options require spyceApache.conf to be modified. Open it up and replace “XXX” with the directory to where you extracted Spyce. The file contains configuration directives for running Spyce behind Apache, running Spyce with FastCGI or CGI and running Spyce through mod_python. Simply uncomment the appropriate section of the file and make sure that all other sections are commented. Next, make a copy of spyceApache.conf and drop it in the conf directory of your Apache installation. Open up Apache's httpd.conf and add this directive to the end:
Spyce should now be configured to work with your method of choice.