How can I load python script into Html ??

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

    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

  • Steve M

    #2
    Re: How can I load python script into Html ??

    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!

    Comment

    • Berislav Lopac

      #3
      Re: How can I load python script into Html ??

      > 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

      Comment

      • Xavier Morel

        #4
        Re: How can I load python script into Html ??

        PatPoul wrote:[color=blue]
        > 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
        >[/color]
        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.

        Comment

        • Xavier Morel

          #5
          Re: How can I load python script into Html ??

          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"/

          Comment

          • Roger Upole

            #6
            Re: How can I load python script into Html ??


            Mozilla is growing python support:


            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" <sjmaster@gmail .com> wrote:[color=blue]
            > 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!
            >[/color]



            ----== 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 =----

            Comment

            • PatPoul

              #7
              Re: How can I load python script into Html ??

              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>

              Comment

              • Tim Roberts

                #8
                Re: How can I load python script into Html ??

                "Steve M" <sjmaster@gmail .com> wrote:[color=blue]
                >
                >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.[/color]

                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, timr@probo.com
                Providenza & Boekelheide, Inc.

                Comment

                • Roger Upole

                  #9
                  Re: How can I load python script into Html ??

                  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" <patpoul23@hotm ail.com> wrote in message news:1134562826 .378663.234100@ g49g2000cwa.goo glegroups.com.. .[color=blue]
                  > 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>
                  >[/color]



                  ----== 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 =----

                  Comment

                  • PatPoul

                    #10
                    Re: How can I load python script into Html ??

                    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

                    Comment

                    • Claudio Grondi

                      #11
                      Re: How can I load python script into Html ??

                      PatPoul wrote:[color=blue]
                      > 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
                      >[/color]

                      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

                      Comment

                      • Roger Upole

                        #12
                        Re: How can I load python script into Html ??


                        "Claudio Grondi" <claudio.grondi @freenet.de> wrote in message news:do7jb2$jcf $1@newsreader3. netcologne.de.. .[color=blue]
                        > PatPoul wrote:[color=green]
                        >> 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
                        >>[/color]
                        >
                        > 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[/color]

                        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 =---

                        Comment

                        Working...