Inkus - python in html

SimpleHTTPServer that renders mako templates

Inkus is a simple html preprocessor that allows you to embed python code into html pages. In a way, it is similar to php, but uses python in code blocks instead.

How is it done?

Basically, Inkus is a SimpleHTTPServer with an overwritten do_GET method. It serves static files (including .html files) in a normal way. However, when a file with an .htm extension is requested it does following things:

  1. searches for a mako template file with the same name and .mako extension
  2. renders the template and
  3. serves resulting html.

What can it do for me?

It provides an easy way to create small static web sites. One-page wordpress site is a nonsense. Real estate agency that manages 5 properties does not really need a CMS either.

Inkus can serve any html template "as is" without any modifications. Make a copy of pages that require special treatment and give them .mako extension. Now they can be accessed as pagename.htm from a browser.

Then you can run Mako templates (and python) magic on them:

  • define blocks of content that should be easily modified,
  • make a layout template and inherit your page templates from it,
  • create python functions directly in the template,
  • fetch those real estate property descriptions and features from an excel file,
  • programmatically rearrange html snippets, etc etc.

Inkus encourages a gradual coversion and does not force you to create new content types unless it is absolutely necessary. It is perfectly OK to leave things as html as long as they are manageable.


Python 2 and 3 are both supported.

You need to install Mako templates, naturally.

pip install Mako

Pygments package is recommended for prettier html error traces.

pip install Pygments


Download inkus from github repository.

How to use it? is a single file. Just drop it into your project folder that contains pages you want to serve and run it. Then open in your browser.

Alternatively, you can put it into some directory in your PATH and make it executable. The trick is always to run it from the project folder.

How can I build a static html site?

Inkus does not have a "build html" command. You need to make a mirror of your locally running website with wget (or some other web spider of your choice).

Install wget for your system. Here is a link to windows binaries. Linux and Mac users should use appropriate package managers.

While inkus is running, from a separate command window run

wget -mkEpnp

Your static html site will be saved to "" folder. Just move the files to your remote web server root folder and you are done.

In case you are wondering, this "-mkEpnp" stands for "--mirror --convert-links --adjust-extension --page-requisites --no-parent".

Additional considerations

Stopping the server

You can stop inkus by pressing Ctrl-C or by visiting special link.

Default page

When you try to open a folder from a browser, inkus

  1. tries to serve index.html file if present
  2. tries to serve index.mako file if present
  3. serves folder listing

So, your default page should be index.mako.

Mysite module

Inkus tries to import module from a local folder. It is a nice place to put some variables that should be initialized only once when the server starts. Global site menu structure, for example.

Current page

Current page location is available from within templates as CURRENT_URI.

Syntax highlighting

Mako is a popular templating language, and it is directly supported by PyCharm and probably other major python IDEs.

Mako Syntax in Sublime Text

There is also language-mako plugin for Atom editor.

Where can I find some good looking HTML templates?

Two biggest template marketplaces is Themeforest and WrapBootstrap.