468,532 Members | 1,716 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,532 developers. It's quick & easy.

How can I load python script into Html ??

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

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

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

<SCRIPT Language="Python">
mytest()
</SCRIPT>
</HTML>
==================================

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

Thx ...
Patrick Poulin

Dec 13 '05 #1
11 3283
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="javascript" src="xxx.js"></script>

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

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

<SCRIPT Language="Python">
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="javascript"/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="Python">
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="Python" 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*******@hotmail.com> wrote in message news:11**********************@g49g2000cwa.googlegr oups.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="Python">
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
PatPoul wrote:
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


In this context I have a question:

How can the registering of the Python scripting engine be easily and
completely removed? (i.e. how can I get rid of it when already registered?)

Claudio
Dec 20 '05 #11

"Claudio Grondi" <cl************@freenet.de> wrote in message news:do**********@newsreader3.netcologne.de...
PatPoul wrote:
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


In this context I have a question:

How can the registering of the Python scripting engine be easily and completely removed? (i.e. how can I get rid of it when
already registered?)

Claudio


Run pyscript.py passing --unregister on the command line.

Roger


----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Dec 20 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

28 posts views Thread by Erik Johnson | last post: by
3 posts views Thread by Josh | last post: by
6 posts views Thread by acord | last post: by
8 posts views Thread by jmDesktop | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.