The Ming Server allows you to create pages using python scripts. The script is run using an os.popen3 call, the output is captured, and is inserted into the site.html. The output is processed by HTMLParser and HTMLMaker. Make sure the python scripts are executable (chmod 755)

To use this data type, you must set the first line in your Python page to

#python

To pass params to your python scripts, include a "params" key in your form data. You can pass multiple params like this:

/cgi-bin/ming.cgi?page=somepage¶ms=one:two:three
Just split the params string on the separator in your script.

Below is a copy of one of my python data type pages as an example. Note that the PYTHON constant is used verbatim as the first line of the file.

Here is a simple example. The package's data directory contains a more complex example which creates and manages user-response pages.


#python

import os, pickle, time

def hdr():
	print """
	<font color=red>Hey!</font> --
	"""
	return

def count():
	LOG = "ming.pob.log"
	if (os.path.isdir("/tmp/persistent")):
		LOG = "/tmp/persistent/"+LOG
	try:
		f = open(LOG)
		dict = pickle.load(f)
		f.close()
		views = dict["last"]
	except:
		views = 0
	print `views`	
	return 


def ftr():
	print """
	of you came by yesterday and not one of you told me what you wanted
	Pobble to do.  You see, I am not a teacher. And rather than take this
	any further on my own, in a direction teachers might not use,
	I'm waiting on you.
	<p>
	Set Pobble up on your own machines, try it out, and think about where it
	should be going.  We can take it anywhere you'd like.  While you're
	thinking about what Pobble could do for you, think about what you would
	like to do for Pobble.
	(The easy answer is
	<a href="http://sourceforge.net/donate/index.php?group_id=97331">money</a>
	-- but little good ever comes from taking the easy way out.)
	<p>
	When you've done your thinking,
	<a href="mailto:billy_bob_ming@yahoo.com">speak up</a>.
	Because if you don't, this is as far as I take this project.  (I took it
	this far to help my daughter learn Spanish.)  Okay then, here I am--ready when
	you are.  Welcome to the Open Source revolution.
	<p>
	Updated: 
	"""
	return

def stamp():
	s = time.ctime(time.time())
	print s[:10]+s[-5:]

hdr()
count()
ftr()
stamp()