views:

48

answers:

2

What are my choices for frameworks for doing Python web development and having a nice language for writing templates for CSS/HTML? A key goal for me is not to have to run a server or install many extra dependencies -- I'd like something that works just by using CGI and hopefully does not force me to do any fancy reconfiguration of Apache etc.

My goal is to write pages that look pretty very easily using templates for generating nice looking HTML with CSS, as opposed to painfully writing out HTML using print statements, and have it be modular. I don't need fancy database support and I am not planning to complex forms for user input that I need to process.

The ideal framework will also have a set of templates written in it that I can use for my website. I essentially just want to make pages programmatically from Python that look good using CSS/HTML without much work.

How can I do this? Something like Django for example would be overkill, since what I am doing is very simple. (Django is great, don't get me wrong, but my purposes are way too simple).

More specifics about my app: I want to make a gallery of photos and also display Python code next to each photo. So I'd like to have a way to easily get syntax highlighting etc. in HTML for Python code. Just like Wordpress has many nice templates for blogs, I'd like a combination of web framework and templating language that has a gallery examples of components I can reuse, so that I don't have to write my own CSS/HTML for making menus/headers/other components of a page look good.

thanks.

+1  A: 

There's some docs, some tools, and some more tools. Plus, flup can turn any WSGI framework into a CGI app. And there's Pygments for syntax highlighting.

Ignacio Vazquez-Abrams
I read that page but there are many options and am not sure where to start. web2py and pylons look great, and there are many nice templating languages. But I don't want to use something that will allow me to use existing web components that just "look good" with CSS -- I don't want to design my own. Just like Wordpress has many nice templates for blogs, I'd like a combination of web framework and templating language that has a gallery examples of components I can reuse, so that I don't have to write my own CSS/HTML for making menus/headers/other components of a page look good.
+1  A: 

Well, you're probably not going to find a framework with templates like that included, simply because that's out of most frameworks' scopes. The page structure, variables, and the like of any given Web application are going to be considerably different from each other, so good generic templates are hard to write. The reason people have so many templates and themes for Wordpress (which, though its authors sometimes promote it as a framework, is just an application) is because there are limits on what you can do with it. Frameworks don't have as many such limits. You are probably going to have to find the templates somewhere else and adapt them to the template language you want to use.

On the subject of template languages, as far as a good, modular template language is concerned, Jinja2 is hard to beat. It's fast, easy to write in, and powerful. I have taken quite a few templates from other Web sites and added the Jinja2 markup relatively effortlessly. Flask is a nice, light framework that works well with it, and it can deploy to CGI. And as for syntax highlighting, I'm going to have to go with Ignacio and recommend Pygments. All of these libraries are well-documented, so you should be able to figure them out easily.

Unfortunately, as much as I would like to have a gallery of reusable theme components, those are not easy to find. You're going to have to scrounge around the Web and hack stuff together yourself.

LeafStorm