1

I know that you can have PHP -code inside HTML -file. I would like to know how you can do the same with Python.

How can you run Python inside a HTML document?

4 Answers 4

3

Look at django templating engine for example. django

2
  • I need to make my SQL queries by myself. I am afraid that I am not allowed to use Django. Jul 26, 2009 at 18:30
  • You can still write your own queries with Django... Although I'll admit that defeats the purpose of using it. Jul 26, 2009 at 18:50
6

Cheetah

Cheetah is a Python-powered template engine and code generator. It may be used as a standalone utility or combined with other tools. Cheetah has many potential uses, but web developers looking for a viable alternative to ASP, JSP, PHP and PSP are expected to be its principle user group.

1
  • @Charles: Cheetah sounds promising. I need to create my SQL queries by myself. Does Cheetah allow me to create my own SQL queries? Jul 26, 2009 at 18:31
3

You will need something like mod_python for apache, or play with cgi.

It really depends on your web server

2
  • There are HTTP servers that are written in plain python. AFAIR python standard library includes one. There's no need to run apache for smale-scale deployments. Jul 26, 2009 at 17:34
  • That's why I said it really depends on the web server :) Jul 26, 2009 at 17:45
0

Use Mako or Jinja2. Both are very fast, and best at doing their job. You should not create SQL queries in your template, but in your controller logic. Later, pass variables/functions to a template and output them.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .