Import Python codes inside HTML file

13,080

That page is related to Karrigell a Python web framework, you can only have Python and HTML files (Web pages) if you use a Python web framework like web.py, Pylons, Django, and others.

Browsers can only execute JavaScript code, other programming languages have to use special components to be executed by browsers.

Share:
13,080

Related videos on Youtube

TheGoodUser
Author by

TheGoodUser

Updated on June 04, 2022

Comments

  • TheGoodUser
    TheGoodUser over 1 year

    As mentioned here, I can import Python codes inside .html files using <% and %> tags. Just to try it, I wrote the below code in notepad and save it as a file named test.html :

    <html>
    <title>
    </title>
    <body>
    <%print ("Hello")%>
    </body>
    

    Once I do a double click on the test.html, Chrome opens with the below line on the top :

    <%print ("Heloo")%>
    

    What I must I do to have 'Hello' in output?

    Note: "print" is an example, What kind of ways is there to import and run python codes in html files?

    • Vizjerei
      Vizjerei over 9 years
      you are using the pythonic web framework?
    • TheGoodUser
      TheGoodUser over 9 years
      @Vizjerei No, What is this? I use Chrome, Firefox , ... Should I add something to this browsers? Or I must use a specific kind of browsers? What is pythonic web framework?
  • TheGoodUser
    TheGoodUser over 9 years
    Thanks. If I want to execute python codes that added to a html codes in Google chrome, I must add some components? If I want to build a web page using python codes inside, How I can be sure the peoples who open my webpage see the outputs that I want? (I mean maybe they haven't a pythonic web framework! so I must not use python codes in my pages?)
  • mpcabd
    mpcabd over 9 years
    That's why you have to use a web framework, where your pages will be handled by Python code on the backend, but clients will only be served HTML web pages. I suggest you read about web development using Python read here
  • TheGoodUser
    TheGoodUser over 9 years
    So the server that we upload our pages there, must have a python web framework? web frameworks translate our pages from python to html,once a request from a client received?
  • mpcabd
    mpcabd over 9 years