Skip to main content

Lightweight jinja2 template prototyping server

Project description

Description

Breakdown is a lightweight python webserver that parses jinja2 templates. It’s intended to be used by designers for doing rapid prototyping.

Basic Usage

Breakdown needs a templates directory and a static directory to serve from. If your working directory contains these, you can simply run breakdown with no arguments:

$ breakdown

Or, you can specify the path to a directory containing templates and static:

$ breakdown /path/to/project

Breakdown will also work with a django project structure. If the project path contains an apps directory, breakdown will automatically detect this and combine the static and templates directories for each django app. You’ll also get a listing of the directories it found. Here’s the output of running breakdown on a django project with two apps: ‘mainsite’ and ‘blog’:

$ breakdown ~/django/myproject
Serving templates from:
  /Users/josh/django/myproject/apps/blog/templates
  /Users/josh/django/myproject/apps/mainsite/templates

Serving static data from:
  /Users/josh/django/myproject/apps/blog/static
  /Users/josh/django/myproject/apps/mainsite/static

Viewing Templates

Once breakdown is running, it will print the local URL the webserver is listening on:

Server running at http://127.0.0.1:5000 ...

You can now view templates in your browser by navigating to http://127.0.0.1:5000. However, you won’t see anything here unless one of your template directories contains a file named index.html. The URL of any template (besides index.html) will be identical to its filename, with all relative paths preserved. Below is an example of template filenames and their corresponding URL on the local server:

Template

URL

index.html

http://127.0.0.1:5000/

article.html

http://127.0.0.1:5000/article

blog/index.html

http://127.0.0.1:5000/blog

blog/post.html

http://127.0.0.1:5000/blog/post

Note: The server will accept template URLs with or without .html appended to them

Additional Features

Template tags

For convenience, A few template functions have been added to the jinja2 template API:

{{ greeking() }}

Generates a block of randomized lorem ipsum text marked-up with various HTML elements: <em>, <strong>, <code>, <a>, <ol>, and <ul>.

{{ image(width, height) }}

If you have PIL installed, you can use this function to generate an <img> tag with a sample image of the specified size (without PIL, the width/height are ignored and you get a large sample image)

CleverCSS

Breakdown also supports automatic CleverCSS parsing. If the file foo.css is requested and not found, breakdown will then look for a matching foo.clevercss and compile it to vanilla css on the fly.

Advanced

Command line options:
-h, --help

show this help message and exit

-p PORT, --port=PORT

run server on an alternate port (default is 5000)

-m, --media

treat MEDIA_URL as STATIC_URL in templates

-v, --version

display the version number and exit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

breakdown-1.0.1.tar.gz (6.3 kB view details)

Uploaded Source

File details

Details for the file breakdown-1.0.1.tar.gz.

File metadata

  • Download URL: breakdown-1.0.1.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for breakdown-1.0.1.tar.gz
Algorithm Hash digest
SHA256 8daf2af70b8b37d3eb7d9fe3b2f4ac56810b9d88cdebab46c24f86f99d934a38
MD5 b0139ed27d48de094d96380d457cc66a
BLAKE2b-256 e83f22c62b06bf07ff6d6f6543805dacc8cebfa14d03eb182e2e50baf7ec1022

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page