473,885 Members | 2,538 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 19660
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****@XXXmagn acartasoftware. com> wrote in message
news:tM******** *************@n ewssvr11.news.p rodigy.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********@jhr othjr.com> wrote in message
news:vn******** ****@news.super news.com...

"Andrew Chalk" <ac****@XXXmagn acartasoftware. com> wrote in message
news:tM******** *************@n ewssvr11.news.p rodigy.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****@XXXmagn acartasoftware. com> wrote in message
news:1t******** *************@n ewssvr11.news.p rodigy.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********@jhr othjr.com> wrote in message
news:vn******** ****@news.super news.com...

"Andrew Chalk" <ac****@XXXmagn acartasoftware. com> wrote in message
news:tM******** *************@n ewssvr11.news.p rodigy.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.add ress.is.invalid > wrote in
message news:1c******** *************** *********@4ax.c om...
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
1737
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 thread and the python script thread). The purpose of doing this is to enable selecting python script to be run from the GUI. any helps please... many thanks.. sarmin
2
2515
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
1662
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 sections: HOW MY SCRIPTS WORKS, and WHAT THE BUG IS.
6
3545
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
3569
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 pass the arguments? Thanks, Olivier.
3
2415
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 think python is worse than perl
0
1464
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 want to do, that is, I want the following syntax to be supported in the host language which I am developing: ###################################################### # scripts in the host language
5
7572
by: Chandra | last post by:
Hi, Is there a way to execute a python script(file) in ASP.NET application (programmatically)?? Regards, Chandra
2
2783
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 in contains no spaces. For example; d:\src\app\app.py If I drag that to the Start Menu it can be executed fine.
0
9956
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10770
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10872
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9592
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7987
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7139
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5808
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6010
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3245
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.