Assembly provides support for writing external scripts. This includes running a development server, a customised Python shell, scripts to set up your database, cronjobs, and other command-line tasks that belong outside the web application itself.

Assembly provides a CLI tool and framework based on Click library

Extension: Click


Upon installing Assembly via pip install assembly, Assembly will setup a command line tool for you to interface with some scripts via the asm command.

There are the Generator commands start with asm gen:* and your custom commands



To initialize Assembly for the first time in the current directory

cd my-dir
asm gen:init


To run the development server.

asm gen:serve

or changing environment

export ASSEMBLY_ENV=Staging 
asm gen:serve

or changing environment and app

export ASSEMBLY_ENV=Testing
export ASSEMBLY_APP=api
asm gen:serve


To sync database models to create new tables. Models that extended db.Model will be created.

asm gen:sync-models


To generate to generate a view file with its associated templates. The view file will be created in /views, and the templates will be in /templates

asm gen:view $view-name


asm gen:view admin


This command can also create a view without templates, by appending --resftul or -x

asm gen:view api --resful

It will create a new module structure in the /modules directory.


If you are serving your assets via CDN or S3, you need to upload them before deploying the application.

When config.ASSETS_DELIVERY_METHOD is S3, this util will allow you to upload your assets to S3, and the application will automatically point all your assets to S3.

asm gen:upload-assets-s3


Return the version of Assembly

asm gen:version

Custom Scripts

Assembly also allows you to create your own CLI scripts, to use with your application.

It's recommended to place your scripts at run/

You probably need CLI to run some routines and setup outside of the web environment, ie: setup database, run worker/task, cronjob, scheduler, etc...

1. Create CLI Functions

Assembly CLI is based on Click library.

Inside of your view, create (named so for discoverability).

NOTE: @command is the alias to the custom command. Use it, otherwise your CLI scripts won't be available.

Learn more about Click

# run/

from assembly.scripts import (command, option, argument, click)

def hello():
  print("Hello world!")

def do_something(name):
  print("Hello %s" % name)

2. Import in


from assembly import Assembly

#->>> Import scripts
import run.scripts

APPS = {
    "default": [

app = Assembly.init(__name__, APPS)

3. Execute Commands

Commands can easily be executed by invoking asm followed by the name of the function that had @command


# run/

from assembly.scripts import (command, option, argument, click)

def hello():
  print("Hello world!")

>> asm hello

def do_something(name):
  print("Hello %s" % name)

>> asm do-something Assembly

it will print out: `Hello Assembly`