473,569 Members | 2,472 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I load python script into Html ??

I want to do the same thing as
<script language="javas cript" src="xxx.js"></script>

but with a python script :
<script language="Pytho n" src="xxx.py"></script>

=============== =============== ====
if xxx.py :
def mytest():
alert("test")
window.document .write('test')
=============== =============== ====
and test.html :
<HTML>
<SCRIPT Language="Pytho n" src="xxx.py"></SCRIPT>

<SCRIPT Language="Pytho n">
mytest()
</SCRIPT>
</HTML>
=============== =============== ====

I always got this error :
NameError : name 'mytest' is not defined

Thx ...
Patrick Poulin

Dec 13 '05 #1
11 3459
Man, I don't even know where to start. There is no way this will work
if you don't have a web browser that can interpret Python. I don't know
of one, and I don't think anybody wants one because using a browser
that would execute arbitrary Python code provided by the server would
be an obscene security mistake.

Javascript is specifically designed for client-side scripting, whereas
Python is not. You'll have to re-think what you wanted to accomplish,
and if it was just "I prefer coding in Python to coding in Javascript"
then you're basically SOL.

Hope this helps!

Dec 13 '05 #2
> Javascript is specifically designed for client-side scripting

Actually, Javascript's client-side implementation is specifically
designed for client-side scripting. It has originally been envisioned
by Netscape for both server and sclient side scripting.

Berislav

Dec 13 '05 #3
PatPoul wrote:
I want to do the same thing as
<script language="javas cript" src="xxx.js"></script>

but with a python script :
<script language="Pytho n" src="xxx.py"></script>

=============== =============== ====
if xxx.py :
def mytest():
alert("test")
window.document .write('test')
=============== =============== ====
and test.html :
<HTML>
<SCRIPT Language="Pytho n" src="xxx.py"></SCRIPT>

<SCRIPT Language="Pytho n">
mytest()
</SCRIPT>
</HTML>
=============== =============== ====

I always got this error :
NameError : name 'mytest' is not defined

Thx ...
Patrick Poulin

Long story short, no.

The browser needs binding to the language, and either the ability to use
the external interpreter or embed an interpreter, and no browser
currently has that kind of thing.
Dec 13 '05 #4
Shouldn't have hit the "send" button so fast...

Addendum: the script element doesn't have any language attribute, the
attribute you're supposed to use is "type" and it takes the MIME type of
your script as a value.

s/language="javas cript"/type="text/javascript"/
Dec 13 '05 #5

Mozilla is growing python support:
http://weblogs.mozillazine.org/roadm...es/008865.html

Using Pywin32, Python can also be registered as an ActiveScript
language so that it can be used in Internet Explorer.

Roger

--
"Ask the ToeCutter - HE knows who I am !"

"Steve M" <sj******@gmail .com> wrote:
Man, I don't even know where to start. There is no way this will work
if you don't have a web browser that can interpret Python. I don't know
of one, and I don't think anybody wants one because using a browser
that would execute arbitrary Python code provided by the server would
be an obscene security mistake.

Javascript is specifically designed for client-side scripting, whereas
Python is not. You'll have to re-think what you wanted to accomplish,
and if it was just "I prefer coding in Python to coding in Javascript"
then you're basically SOL.

Hope this helps!


----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Dec 14 '05 #6
Sorry I was not clear, my setup is functionnal with Pywin32.
Python 2.4 + pywin32

and actually, I can do this kind of script on client side :

<HTML>
<SCRIPT Language="Pytho n">
alert('test')
</SCRIPT>
</HTML>

but I want to include external python script with the HTML tag <SCRIPT>

Dec 14 '05 #7
"Steve M" <sj******@gmail .com> wrote:

Man, I don't even know where to start. There is no way this will work
if you don't have a web browser that can interpret Python. I don't know
of one, and I don't think anybody wants one because using a browser
that would execute arbitrary Python code provided by the server would
be an obscene security mistake.


Internet Explorer will happily do so, if you have the Python Windows
extensions installed, and register the active scripting component that cmes
with it.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Dec 16 '05 #8
Using the normail src attribute works for me:

<SCRIPT Language="Pytho n" src="somescript .pys"></script>

Did you register the Python script engine with pyscript.py or
pyscript_rexec. py ?

Roger
--
"Ask the ToeCutter - HE knows who I am !"
"PatPoul" <pa*******@hotm ail.com> wrote in message news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Sorry I was not clear, my setup is functionnal with Pywin32.
Python 2.4 + pywin32

and actually, I can do this kind of script on client side :

<HTML>
<SCRIPT Language="Pytho n">
alert('test')
</SCRIPT>
</HTML>

but I want to include external python script with the HTML tag <SCRIPT>


----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Dec 16 '05 #9
Yes I register Python script.
I see in your exemple that you use file extention pys.
That was why my exemple does'nt work.

Thanks !

Patrick Poulin

Dec 19 '05 #10

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

Similar topics

28
4589
by: Erik Johnson | last post by:
This is somewhat a NEWBIE question... My company maintains a small RDBS driven website. We currently generate HTML using PHP. I've hacked a bit in Python, and generally think it is a rather cool language. I've done Perl and like it, there are a few features of PHP I like but overall am not too excited about it. I have found PHP's...
3
3192
by: Josh | last post by:
Hi - A couple days ago I posted asking for help on how to download a pushed file. I am trying to write a script to download a bunch of links from a page that takes a while to load. I managed to get just about everything done using python to load IE, but aside from not really liking that style, I couldnt figure out how to have python...
1
4306
by: rh | last post by:
Executing the script given below Opera, Netscape and Mozilla successfully load the js file in both the "main" and "test" window. However, while IE 6 manages to load OK in "main", it produces the "Load failed in test" alert. IE behaviour is the same if a local file is used for the js source, so the problem doesn't appear to be zone security...
6
3071
by: acord | last post by:
Hi, In a html page, I don't know how to load in a php page from javascript. I've already defined a <div id="treemenu"> in the html page. The executed content from the php script is supposed loaded into the treemenu div. What is the best way to achieve this? I got error where the treemenu didn't close/open on the treenode, as when I clicked...
8
2293
by: Eric_Dexter | last post by:
I was looking for a simple way to load a simple python program from another python program. I tried os.system(cabel) The file name is cabel.py a csound instrument editor.. The error I am getting is
8
1576
by: jmDesktop | last post by:
I have been to the main python site, but am still confused. I have been using .net, so it may be obvious how to do this to everyone else. I am aware there are various frameworks (Django, Pylons, etc.), but I would like to know how to create web pages without these. If I have mod_python or fastcgi on apache, where do I start? I don't have...
0
1588
by: eddiefisher41 | last post by:
Hey guys. Im having problems running a python cgi. Im using the example code from: http://www.python.org/doc/essays/ppt/sd99east/sld041.htm as writen by Van Rossum himself I can get the script to run the python script but all that happens is that the black python box appears then disapears, the html that the python scripts should generate is...
0
7703
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...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6287
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...
0
3657
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...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
946
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...

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.