Welcome To HelpOut! The Home for All Your Questions
asked Mar 17 in Engineering & Technology by (130 points)

3 Answers

0 like 0 dislike
answered Mar 17 by anonymous

See here for how to embed python codes in Html.

0 like 0 dislike
answered Mar 17 by The Finder

Python Inside HTML:

Python Inside HTML behaves much like Microsoft's Active Server Pages, Sun's Java Server Pages and PHP : it's basically a HTML document, in which you insert portions of code written in a programming language - here Python In Python Inside HTML, these portions of code are separated from the HTML code inside special tags :<% and %> 

Suppose you want to display the current date, you'll mix html and Python code this way : The current date is: 

<% import datetime

 print datetime.date.today().strftime("%d:%m:%y") 


With a text editor, write the code above and save it under time.pih in your Root Directory. Enter http://localhost/time.pih and see what happens.  

You'll notice that the code inside the <% and %> tags is ordinary Python code, in which you can import modules, create and instanciate classes, use variables, read or write to the file system, etc. 

Access to HTTP environment, to form fields, to the exceptions defined by Karrigell are made the same way as in Python Scripts

See here for more details.

0 like 0 dislike
answered Mar 22 by (140 points)
There are several ways in which python can be integrated with HTML which is a markup language. These are some of the most popular methods.

Low-Level View. The user makes a request with the server when they enter any website.

CGI: Common Gateway Interface. It is the oldest and most supported interfaced used by web servers.

mod_python. People that are from the PHP or JS background usually find it difficult to understand python.


WSGI Server.