Aspen

A Python web framework that makes the most of the filesystem.
Simplates are the main attraction.

mime.types

Aspen automatically sets the Content-Type response header based on the file extension of the simplate file being served (you can override this behavior by setting the header manually in your simplates). Aspen instructs the mimetypes module in the Python standard library to use the following mappings to determine which Content-Type to use for which file extension.

Later definitions override earlier ones.

Example

Let’s say that you want to use the .smpl file extension to denote simplates on your filesystem. You might want to do this because it’s easier to configure your text editor based on a unique extension.

Create a file named greetings.smpl with this content:

<h1>Greetings, program!</h1>

Now hit it with your browser:

You get a text/plain response, because the .smpl extension is unknown to Aspen, and text/plain is Aspen’s default.

Now put the following line in a file named mime.types in your site’s project_root directory (note the lack of a period before smpl).

text/html  smpl

Restart aspen to pick up the new mime.types file, and then hit foo.smpl again. You should now have a rendered HTML file:

Home