Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
add comment

4 Answers

up vote 2 down vote accepted

Look at django templating engine for example. django

share|improve this answer
    
I need to make my SQL queries by myself. I am afraid that I am not allowed to use Django. –  Masi Jul 26 '09 at 18:30
    
You can still write your own queries with Django... Although I'll admit that defeats the purpose of using it. –  Sasha Chedygov Jul 26 '09 at 18:50
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
    
@Charles: Cheetah sounds promising. I need to create my SQL queries by myself. Does Cheetah allow me to create my own SQL queries? –  Masi Jul 26 '09 at 18:31
add comment

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

It really depends on your web server

share|improve this answer
    
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. –  Tadeusz A. Kadłubowski Jul 26 '09 at 17:34
    
That's why I said it really depends on the web server :) –  Yoann Le Touche Jul 26 '09 at 17:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.