473,322 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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.
Jul 18 '05 #1
7 19613
Andrew Chalk:
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.


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

--
René Pijlman
Jul 18 '05 #2

"Andrew Chalk" <ac****@XXXmagnacartasoftware.com> wrote in message
news:tM*********************@newssvr11.news.prodig y.com...
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.
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

Many thanks.

Jul 18 '05 #3
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" <ne********@jhrothjr.com> wrote in message
news:vn************@news.supernews.com...

"Andrew Chalk" <ac****@XXXmagnacartasoftware.com> wrote in message
news:tM*********************@newssvr11.news.prodig y.com...
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.


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

Many thanks.


Jul 18 '05 #4
[Andrew Chalk]
I want to run the script on the server.
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.
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?


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
Jul 18 '05 #5

"Andrew Chalk" <ac****@XXXmagnacartasoftware.com> wrote in message
news:1t*********************@newssvr11.news.prodig y.com...
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.
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

"John Roth" <ne********@jhrothjr.com> wrote in message
news:vn************@news.supernews.com...

"Andrew Chalk" <ac****@XXXmagnacartasoftware.com> wrote in message
news:tM*********************@newssvr11.news.prodig y.com...
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.


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

Many thanks.



Jul 18 '05 #6
Thanks!
"Rene Pijlman" <re********************@my.address.is.invalid> wrote in
message news:1c********************************@4ax.com...
Andrew Chalk:
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 goto an HTML page.


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

--
René Pijlman

Jul 18 '05 #7
Thanks!
"Alan Kennedy" <al****@hotmail.com> wrote in message
news:3F***************@hotmail.com...
[Andrew Chalk]
I want to run the script on the server.


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.
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?


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

Jul 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: sarmin kho | last post by:
Hi Python Guru, I ve created a GUI using Boa constructor and am now trying to execute a python script when pressing a button on the GUI. So, there will then be two main threads running (the GUI...
2
by: wonder | last post by:
Hi, How can I pass the url of the current webpage link to a python script in html? thanks sam
6
by: Dfenestr8 | last post by:
Hi. I've written a cgi messageboard script in python, for an irc chan I happen to frequent. Bear with me, it's hard for me to describe what the bug is. So I've divided this post into two...
6
by: Olly | last post by:
I've found a basic script, however I also need to add alt and title attributes as well, how would I go about doing this? Here's the script I found: Thanks <script language="JavaScript"> <!--...
3
by: olaufr | last post by:
Hi, I need to call a python script, with command line arguments (it is an autonomous script with a __main__), from within another python script. Can I use exec() or execfile() for this? How to...
3
by: Pankaj | last post by:
I am facing a very basic problem as any new bie would face. I know perl and now i want to use python In perl, it is very simple , just "perl scriptname.pl" will execute the script. But i...
0
by: phoolimin | last post by:
Dear all, I am trying to embed python into another scripting language, to do this I need to solve a number of problems on importing or compiling python script. First let me state what exactly I...
5
by: Chandra | last post by:
Hi, Is there a way to execute a python script(file) in ASP.NET application (programmatically)?? Regards, Chandra
2
by: Jorgen Bodde | last post by:
Hi all, This is slightly OT but it drives me nuts. Whenever I create a shortcut in the start menu (in Windows) of a python script, it will only execute it when the path where the script resides...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.