Developer’s notes

Frequently asked questions

Another web framework, are you kidding me?

Fiole is a new challenger in the category of the Python micro-frameworks. As you probably know, there are very good competitors in the market and we don’t really need a new one.

Read the introduction for a quick outline of the development guidelines for the Fiole framework.

So, how Fiole is different or similar to the others?

  • is the first in the series, created in January 2006 by Aaron Swartz (aaronsw). It has no dependency and it supports old versions of Python, but it is not compatible with Python 3. It is a whole package and it provides additional features, while Fiole focuses on the essentials. does not support the decorator syntax, compared with more recent frameworks.
  • is a single-file micro-framework experiment, released on March 2009. It is the first Sinatra-influenced Python framework. However, it does not have public tests, and it does not ship a template engine.
  • Bottle is a micro-web framework born on July 2009. Fiole is similar to Bottle because it is a single file, inspired by, with no dependency. It embeds a template engine, which has a syntax close to Bottle’s SimpleTemplate. When it comes to the differences, Fiole template engine is faster, and its source code is smaller and follows the PEP 8 guidelines. On the other side Bottle has more features.
  • Flask is the successor of Denied, born on 1st April 2010. It is a great framework with a must-read documentation. Flask is a package which depends on Werkzeug and Jinja. In contrast with it, Fiole is a single file without external dependencies and with a lot less documentation and less features. Flask has many extensions.

To sum up:

  • Fiole is a single file like and Bottle
  • Fiole has no dependency, same as, and Bottle
  • Fiole embeds a template engine similar to and Bottle
  • Fiole supports the decorator syntax like, Bottle and Flask
  • Fiole supports signed cookies like Flask does
  • Fiole source code is PEP8-compliant like and Flask
  • Fiole supports Python 3 like Bottle and Flask
  • Fiole supports hooks like Bottle and Flask
  • Fiole does not have an extensive documentation like Flask or Bottle
  • Fiole does not provide built-in adapters for every WSGI server like or Bottle

Of course the above comparison is partial and subjective.

How much is it extensible?

Fiole is thread-safe and you can configure more than one application (for complex projects).

Fiole supports hooks which can be registered for each application. Moreover, the components of Fiole are well thought to allow extensibility. For example the template engine is configurable through attributes, and all the components of the template engine can be subclassed easily.

As an alternative, you can use any template engine, such as Jinja or Mako instead of the built-in template engine. There’s no specific integration between Fiole and the built-in template Engine.

Only the adapter for the wsgiref server is provided. You can write your own adapter for your preferred WSGI server. There are examples available in Bottle or source code for example.

How to make my application really fast?

First, I am not an expert about this topic. Still, there are various places where you can improve the performance of your web application. Some ideas that come to my mind:

  • use a reverse proxy (nginx, ...)
  • delegate serving static files to the proxy
  • enable on-the-fly gzip compression on the proxy
  • provide the relevant HTTP headers to enable browser caching
  • replace the WSGI server with a scalable WSGI server which supports concurrency
  • add server caching
  • use load-balancing
  • switch to PyPy

The template engine is already very fast. Even so, you can achieve a better performance with small changes:

  • disable default_filters and use the |str filter only when needed
  • replace the escape filter with a C implementation (e.g. Webext)

However the first thing to do is to benchmark your own application with realistic data in order to know where is the bottleneck before doing any random optimization.

I need only the template engine, can you release it?

Indeed, the template engine has some benefits: it is compact (~450 lines of code) and it is rather intuitive (basically, it’s Python syntax). It is derived from the wheezy.template package which is very fast.

The template engine can be used to process any kind of text.

The good news is that the template engine is not bound to the web framework. Currently there’s no plan to release it separately because Fiole is already a very small module and there’s nothing wrong using only one of its two components: the web framework or the template engine.

Source code

The source code is available on GitHub under the terms and conditions of the BSD license. Fork away!

The tests are run against Python 2.7, 3.2 to 3.4 and PyPy on the Travis-CI platform.

Project on PyPI:


0.4.1 (2014-07-03)

  • Replace deprecated cgi.escape with a copy of Python 3.4’s html.escape.

0.4 (2014-07-02)

  • Add Request.host_url, Request.script_name and Request.get_url(path, full=False). (Issue #4)
  • Add |n filter to disable default filters. (Issue #5)
  • Fix caching of Request.accept* headers.

0.3 (2013-06-12)

  • Improve the documentation.
  • Add the Fiole application to the WSGI environment: environ['']. (Issue #1)
  • Implement parsing of the Accept headers, and add them as dynamic properties of Request: accept, accept_charset, accept_encoding and accept_language. (Issue #2)
  • Replace the global SECRET_KEY with a new attribute of the Fiole application app.secret_key.
  • Replace the helpers _create_signed_value and _decode_signed_value with methods: Fiole.encode_signed() and Fiole.decode_signed(). The method Response.create_signed_value() is removed too.
  • Remove argument secret from the run_fiole function: use get_app().secret_key = 's3c4e7k3y...' instead.
  • The send_file helper recognizes the If-Modified-Since header and returns “304 Not Modified” appropriately.
  • Patch the wsgiref.simple_server.ServerHandler to stop sending Content-Length for status “304 Not Modified”. (This is related to a Python bug)
  • Add Fiole.debug boolean flag to let unhandled exceptions propagate.
  • Rename helper html_escape to escape_html.
  • Add default_filters for the template engine configuration.
  • Automatically cast Python objects to Unicode for template rendering. This can be disabled with engine.default_filters = None.
  • Refactor the internals of the template engine. New method Engine.clear() to reset the cache of byte-compiled templates.
  • Support extensibility of the WSGI application with hooks.

0.2 (2013-05-22)

  • Initial release.