2. Architecture

Tozti serves 3 main HTTP namespaces:

  • /static: usual static files (javascript, css, images, etc)
  • /api: REST endpoints to interact with the server
  • anything else will be responded to with the main index.html

2.1. Extensions

The tozti core is really lightweight but it has the ability to load extensions. During the startup, the server will search for extensions in the extensions subfolder of the tozti repository root.

2.1.1. Directory structure and server.py

The tozti core is really lightweight but it has the ability to load extensions. For now, you only need to know that extension is a folder providing a python file (server.py or server/__init__.py), describing how the extension works on the server (its routes, which files must be included from the client). This file must contain a global variable MANIFEST that is a dictionary containing the following keys (any one being optional):

name
The name of the extension, in lower-case and with dashes instead of spaces.
includes
A list of css or js files that must be included in the main index.html. Usually you will put there "main.js" which contains the code to register or patch components. The file paths must be relative to the dist subfolder of the extension (see below).
_god_mode
Beware, this can be dangerous if used incorrectly! This should be a function taking as argument the main aiohttp.web.Application object. You can use it to register custom middlewares or do otherwise weird stuff.

The extension can contain a dist folder. The content of this folder will be served at the URL /static/<extension-name>.

2.1.2. Vuejs initialization