[Tutor] Confused about embedding python in Html

Alan G alan.gauld at freenet.co.uk
Sun Aug 21 16:01:24 CEST 2005


Hi Tony,

> I want to use embedded python in an html page.

I assume you mean you want to embed python code in amongst
your HTML and have it executed at the server in the same way
as ASP?

There is a system available called PSP - Python Server Pages
which allows this but be aware that because of Python's
indentation rules its more complex that it might seem.

Its usually easier to embed HTML into your Python code as a CGI script

> However, I dont want to force the user to have python installed for 
> the page to work.

Thats OK, most web frameworks work by having the server execute the 
code.
Any client side scripting must be done in JavaScript if you want to 
have
any chance of browser compatibility.

> Is there any way to make the embedded python code be executed by the 
> server?
> I'm hoping ti use python as an alternative to vbscript and jaava

VBScript and Java are often used client side - especially where you 
canbe
sure the browwer is IE, however with ASP and JSP both can be used 
server
side too. It depends on how you are using them whether you can replace
with Python.

As a general guide I'd recommend using CGI for server side python, 
serving
up HTML pages with embedded JavaScript where you really need client 
side
scripting.

HTH,

Alan G. 



More information about the Tutor mailing list