What's the very simplest way to run some Python from a button on a web page?

tinnews at isbd.co.uk tinnews at isbd.co.uk
Sun Jan 22 05:04:07 EST 2012

Tim Roberts <timr at probo.com> wrote:
> tinnews at isbd.co.uk wrote:
> >
> >I want to run a server side python script when a button on a web page
> >is clicked.  This is on a LAMP server - apache2 on xubuntu 11.10.
> >
> >I know I *could* run it as a CGI script but I don't want to change the
> >web page at all when the button is clicked (I'll see the effect
> >elsewhere on the screen anyway) so normal CGI isn't ideal.
> It seems what you're after is AJAX.  If you are using a Javascript
> framework like jQuery, it's easy to fire off an asynchronous request back
> to your server that leaves the existing page alone.  If you aren't, then I
> think the easiest method is to use an invisible <iframe>.  From Javascript,
> you can set the "src" property of the <iframe> to fire off a request while
> leaving the rest of the page alone.
OK, thanks, I'd sort of found that the answer seems to be AJAX but now
you have confirmed it I'll start looking harder.

> You could spend the rest of your career reading all of the good web
> material on AJAX.


Chris Green

More information about the Python-list mailing list