Load a python script from html

Tim Roberts timr at probo.com
Tue Aug 6 07:38:44 CEST 2002


dub98xfs at ureach.com (Samantha) wrote:
>
>I am trying to have a python script executed when I load a html page.
>
>I typed this in the html page
><!--exec location/of/python location/of/python/script-->
>
>where the script has world executable permissions and the prog does
>not execute. I even put quotes around the location of the python
>location to no avail.
>
>Is there some other workable way to get the proggy to execute?
>
>(sorry if I am asking the wrong newsgroup here)

The newsgroup is fine, but I think you're asking the wrong question.

Do you want the script to execute on the web SERVER, where the HTML page is
located?  That's the syntax you have above.  You need to change the
extension of the page to .shtml to get the server to scan it for directives
like this.

Do you want the script to execute in the web BROWSER, where you are reading
the page?  That's harder, because it is a security risk.  You can try this:

<script language="Python">
exec "location_of_python_script.py"
</script>

but I don't know if the "exec" command is allowed in scripted Python.
--
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list