Zerho
Zerho

Reputation: 1460

Can Python be embedded in HTML like PHP and JSP?

Is there a way of writing Python embedded in HTML like I do with PHP or JSP?

Upvotes: 24

Views: 42424

Answers (5)

Rafe Kettler
Rafe Kettler

Reputation: 76965

Several templating engines support this in one way or another: Mako, Jinja, and Genshi are all popular choices.

Different engines support different features of Python and may be better suited to your needs. Your best bet is to try them out and see what works.

Upvotes: 2

Dolph
Dolph

Reputation: 50710

Use a template engine, such as:

The python wiki also has an article on this topic, with many more suggestions.

Upvotes: 23

Arafangion
Arafangion

Reputation: 11940

There is... But you're highly suggested to use a templating engine, or some other means of separating the presentation from the business layer.

There are some available that use python as the templating language, but it's nasty because python is sensitive to whitespace, so special syntax hacks have to be added.

Upvotes: 7

methyl
methyl

Reputation: 3322

Use Cheetah or another templating engine.

Upvotes: 1

kojiro
kojiro

Reputation: 77157

Yes, I recall there was a python ASP plugin from activestate that works this way.

Upvotes: 0

Related Questions