Executing a python script from an HTML link?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew Chalk

    Executing a python script from an HTML link?

    Is this possible? In my CGI app. I display a web page with a link (anchor).
    When the link is clicked I want to exectute a python script rather than go
    to an HTML page.

    Many thanks.


  • Rene Pijlman

    #2
    Re: Executing a python script from an HTML link?

    Andrew Chalk:[color=blue]
    >Is this possible? In my CGI app. I display a web page with a link (anchor).
    >When the link is clicked I want to exectute a python script rather than go
    >to an HTML page.[/color]

    IIUYC: make the link tot a Python CGI script instead of to an HTML page.

    --
    René Pijlman

    Comment

    • John Roth

      #3
      Re: Executing a python script from an HTML link?


      "Andrew Chalk" <achalk@XXXmagn acartasoftware. com> wrote in message
      news:tMYbb.382$ zy3.566196578@n ewssvr11.news.p rodigy.com...[color=blue]
      > Is this possible? In my CGI app. I display a web page with a link[/color]
      (anchor).[color=blue]
      > When the link is clicked I want to exectute a python script rather than go
      > to an HTML page.[/color]

      Do you want to run the script on the server or the client? If you
      want to run it on the client, you can use Python instead of Javascript
      (or in addition to Javascript) in the web page. Look at the <script>
      tag for the language (I think that's the one - I haven't looked it up
      recently) attribute. Otherwise, just invoke Python the same way you would
      invoke any other executable, and use the script name as the
      first parameter.

      John Roth
      [color=blue]
      >
      > Many thanks.
      >
      >[/color]


      Comment

      • Andrew Chalk

        #4
        Re: Executing a python script from an HTML link?

        Thanks. I want to run the script on the server. The problem is that I don't
        have an html page as an HREF. Viz:

        <tr><A HREF="Fred.htm" >Fred</A>
        What replaces Fred.htm to invoke a server-side script?
        Regards.


        "John Roth" <newsgroups@jhr othjr.com> wrote in message
        news:vn0tdkg96j lcc7@news.super news.com...[color=blue]
        >
        > "Andrew Chalk" <achalk@XXXmagn acartasoftware. com> wrote in message
        > news:tMYbb.382$ zy3.566196578@n ewssvr11.news.p rodigy.com...[color=green]
        > > Is this possible? In my CGI app. I display a web page with a link[/color]
        > (anchor).[color=green]
        > > When the link is clicked I want to exectute a python script rather than[/color][/color]
        go[color=blue][color=green]
        > > to an HTML page.[/color]
        >
        > Do you want to run the script on the server or the client? If you
        > want to run it on the client, you can use Python instead of Javascript
        > (or in addition to Javascript) in the web page. Look at the <script>
        > tag for the language (I think that's the one - I haven't looked it up
        > recently) attribute. Otherwise, just invoke Python the same way you would
        > invoke any other executable, and use the script name as the
        > first parameter.
        >
        > John Roth
        >[color=green]
        > >
        > > Many thanks.
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Alan Kennedy

          #5
          Re: Executing a python script from an HTML link?

          [Andrew Chalk][color=blue]
          > I want to run the script on the server.[/color]

          Then you will need to figure out how to run the script on the server
          ;-)

          If you're not aware of how to do this, then it's probably best for you
          to read up on CGI, which is way of getting web servers to execute
          scripts (in any language) when the scripts URL is requested.
          [color=blue]
          > The problem is that I don't
          > have an html page as an HREF. Viz:
          >
          > <tr><A HREF="Fred.htm" >Fred</A>
          > What replaces Fred.htm to invoke a server-side script?[/color]

          Whatever is the URL of your script on your server. Examples include





          Your python script should then generate (i.e. print out) an HTML page
          when it is run (actually it can generate anything, images included,
          but HTML is a good place to start). The server takes the output of
          your script and sends it to the requesting browser. The browser has no
          way of knowing that the HTML did not come from a static file.

          You can read about Python and CGI here:-



          There are other "linkage mechanisms" by which you can cause the
          execution of scripts on a server, e.g. mod_python, but none is
          conceptually as simple as CGI. Also, CGI tends to be more portable
          between different server software, and is almost always supported by
          hosting providers.

          HTH,

          --
          alan kennedy
          -----------------------------------------------------
          check http headers here: http://xhaus.com/headers
          email alan: http://xhaus.com/mailto/alan

          Comment

          • John Roth

            #6
            Re: Executing a python script from an HTML link?


            "Andrew Chalk" <achalk@XXXmagn acartasoftware. com> wrote in message
            news:1t%bb.407$ Q44.601209120@n ewssvr11.news.p rodigy.com...[color=blue]
            > Thanks. I want to run the script on the server. The problem is that I[/color]
            don't[color=blue]
            > have an html page as an HREF. Viz:
            >
            > <tr><A HREF="Fred.htm" >Fred</A>
            > What replaces Fred.htm to invoke a server-side script?
            > Regards.[/color]

            That's not a Python issue. It's a web server configuration
            issue. You should be able to configure your web server
            to recognize href="fred.py" as a request to run the fred.py
            script using the Python interpreter, and pass back whatever
            web page, graphic or other file it outputs. For that matter,
            you might even be able to configure it to recognize
            "Fred.htm" as a python script, and rewrite the name
            to "fred.py."

            John Roth[color=blue]
            >
            >
            > "John Roth" <newsgroups@jhr othjr.com> wrote in message
            > news:vn0tdkg96j lcc7@news.super news.com...[color=green]
            > >
            > > "Andrew Chalk" <achalk@XXXmagn acartasoftware. com> wrote in message
            > > news:tMYbb.382$ zy3.566196578@n ewssvr11.news.p rodigy.com...[color=darkred]
            > > > Is this possible? In my CGI app. I display a web page with a link[/color]
            > > (anchor).[color=darkred]
            > > > When the link is clicked I want to exectute a python script rather[/color][/color][/color]
            than[color=blue]
            > go[color=green][color=darkred]
            > > > to an HTML page.[/color]
            > >
            > > Do you want to run the script on the server or the client? If you
            > > want to run it on the client, you can use Python instead of Javascript
            > > (or in addition to Javascript) in the web page. Look at the <script>
            > > tag for the language (I think that's the one - I haven't looked it up
            > > recently) attribute. Otherwise, just invoke Python the same way you[/color][/color]
            would[color=blue][color=green]
            > > invoke any other executable, and use the script name as the
            > > first parameter.
            > >
            > > John Roth
            > >[color=darkred]
            > > >
            > > > Many thanks.
            > > >
            > > >[/color]
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Andrew Chalk

              #7
              Re: Executing a python script from an HTML link?

              Thanks!
              "Rene Pijlman" <reply.in.the.n ewsgroup@my.add ress.is.invalid > wrote in
              message news:1co0nvk1h6 0qagov4v60874gr ijiscvluq@4ax.c om...[color=blue]
              > Andrew Chalk:[color=green]
              > >Is this possible? In my CGI app. I display a web page with a link[/color][/color]
              (anchor).[color=blue][color=green]
              > >When the link is clicked I want to exectute a python script rather than[/color][/color]
              go[color=blue][color=green]
              > >to an HTML page.[/color]
              >
              > IIUYC: make the link tot a Python CGI script instead of to an HTML page.
              >
              > --
              > René Pijlman[/color]


              Comment

              • Andrew Chalk

                #8
                Re: Executing a python script from an HTML link?

                Thanks!
                "Alan Kennedy" <alanmk@hotmail .com> wrote in message
                news:3F7089DA.E B6E9969@hotmail .com...[color=blue]
                > [Andrew Chalk][color=green]
                > > I want to run the script on the server.[/color]
                >
                > Then you will need to figure out how to run the script on the server
                > ;-)
                >
                > If you're not aware of how to do this, then it's probably best for you
                > to read up on CGI, which is way of getting web servers to execute
                > scripts (in any language) when the scripts URL is requested.
                >[color=green]
                > > The problem is that I don't
                > > have an html page as an HREF. Viz:
                > >
                > > <tr><A HREF="Fred.htm" >Fred</A>
                > > What replaces Fred.htm to invoke a server-side script?[/color]
                >
                > Whatever is the URL of your script on your server. Examples include
                >
                > http://www.mydomain.com/cgi-bin/myscript.py
                > http://www.mydomain.com/cgi-bin/myscript.cgi
                > http://www.mydomain.com/cgi-bin/mysc...A=v1&paramB=v2
                >
                > Your python script should then generate (i.e. print out) an HTML page
                > when it is run (actually it can generate anything, images included,
                > but HTML is a good place to start). The server takes the output of
                > your script and sends it to the requesting browser. The browser has no
                > way of knowing that the HTML did not come from a static file.
                >
                > You can read about Python and CGI here:-
                >
                > http://starship.python.net/crew/dave....cgi?req=index
                >
                > There are other "linkage mechanisms" by which you can cause the
                > execution of scripts on a server, e.g. mod_python, but none is
                > conceptually as simple as CGI. Also, CGI tends to be more portable
                > between different server software, and is almost always supported by
                > hosting providers.
                >
                > HTH,
                >
                > --
                > alan kennedy
                > -----------------------------------------------------
                > check http headers here: http://xhaus.com/headers
                > email alan: http://xhaus.com/mailto/alan[/color]


                Comment

                Working...