Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Travis CI: Build Status


Circular is a Python web-framework somewhat similar to AngularJS 1. It is built upon the Brython python-to-js compiler.

Using Circular

Currently, the code is not yet ready for use. If you are adventurous, you can look at web_src/index.html. There are several steps you need to do:

Include Brython

First install Brython (note that currently Brython version 2.6 is needed) and then put the following in the <head> section of your html:

    <script type="text/javascript" src="">
        var onLoadHandler = function() {

and then

    <body onload="onLoadHandler()">

to load initialize it and run the python scripts (shown later).

Include the circular library

Next add the following into your head section

<link rel="pythonpath" href="lib" hreflang="py" />

replacing lib with the url of the place where the circular directory with the library is located.

Write a template

For example, you could include the following in your body

    <div id='test'>
        Hello {{ name }}, how are you? Which is your favourite colour?
            <li tpl-for='c in colours' class='{{ c["css"] }}'> c["name"] </li>

Initialize the library & parse the template

Put a Python script tag into your head (eventually, you would put it into a separate file, but for simplicity we include it in the head)

<script type="text/python">


and put the following python code inside:

from browser import document as doc

from circular.template import Template, Context

Template.set_prefix('tpl-')             # Sets the prefix used to identify template tags (e.g. tpl-for)
tpl = Template(doc['test_tpl'])         # Parses the template contained in the <div id='test'> dom element
ctx = Context()                         # Creates a new context (placeholder for data which can be used in the template)
tpl.bind_ctx(ctx)                       # Binds the context to the template (this populates the template with the data)
                                        # Initially the context does not contain any data so the rendered template will
                                        # not contain much.'Jonathan'                     # Set the name and colours variables
ctx.colours = [{"css":'red',"name":"Red"},{"css":'green',"name":"Green"},{"css":'blue',"name":'Blue'}]

                                        # After a while (approx. 100 msecs) the template should automatically update
                                        # with the new values

When you load the page it will take some time to initialize (load Brython), and import the circular library. Eventually it should result in a page which looks something like

    <div id='test'>
        Hello Jonathan, how are you? Which is your favourite colour?
          <li class='red'>Red</li>
          <li class='green'>Green</li>
          <li class='blue'>Blue</li>


Source code

To get the source do:

$ git clone
$ cd circular
$ git submodule init
$ git submodule update

(the last two steps pull in the Brython dependency)

The sources for the library are in the src/circular subfolder. Eventually I intend to provide p more documentation. Currently just use the source (and the tests in tests/circular directory).

For development purposes there is a webpage which contains a python console and a test template where you can experiment with the library and your changes to it. This webpage is located in web_src. The page uses some stylesheets which are compiled from Sass sources and icons from the Material Design Icons.

Fabric is used to automate building the stylesheets and copying them to the right place (www/css, www/fonts). You can install fabric either using pip (e.g. pip install fabric) or your package manager (e.g. sudo apt-get install fabric). Then compiling and copying the stylesheets is just a matter of

$ fab web.deploy

Note that some python libraries are used to compile the sass source. To install them use

$ fab test.mkenv

to build a virtual-env with the necessary packages and then modify management/web/ to point to the right directory (sorry, I know this is ugly, but I didn't have the time to change it yet and it works for me :-))

To serve the test page, just run

$ fab web.serve

(which really is just a shortcut for python -m SimpleHTTPServer) and point your browser to http://localhost:8000.


The project uses the Issue tracker at GitLab.


Tests are based on the pytest testing framework for Python and are run using

$ fab test.all

(or fab test.single:template/ for a single test file; this drops you into a pdb shell in case of failure)


The project is licensed under the MIT license.


A Python web-framework somewhat similar to AngularJS v1







No releases published


No packages published