Live Chat

We'll need to share your messages (and your email address if you're logged in) with our live chat provider, Drift. Here's their privacy policy.

If you don't want to do this, you can email us instead at contact@anvil.works.

Python directory structure

Your app is stored as a directory structure that you can clone using Git. Each Package, Module and Form consists of files and directories within this structure.

Packages

Packages (and Server Packages) are Python packages - directories containing an __init__.py file:

Package1
└── __init__.py

Forms

Each Form is also a Python package: the __init__.py contains what you see in the Code View for that Form. There’s also a config file that describes the UI design for the Form, named form_template.yaml:

Form1
├── __init__.py
└── form_template.yaml

Modules

Modules (and Server Modules) are simply ordinary files; a Module named Module1 is a Python file named Module1.py.

Package1
├── __init__.py
└── Module1.py

Server vs. Client

Server-side and client-side code are stored in separate directories in the repo. When you check out your app using Git, you’ll see directories named server_code and client_code:

MyApp
├── __init__.py
├── anvil.yaml
├── client_code
├── server_code
└── theme

Example

Here’s an example of the structure of an app in Anvil, and the underlying directory structure in the Git repo. The Anvil representation is this:

Example app in Anvil.
See below for its directory structure.

Example app in Anvil.
See below for its directory structure.

Its repo has the following directory structure:

MachineInventory
├── __init__.py
├── anvil.yaml
├── client_code
│   ├── DataProcessor.py
│   ├── Machines
│   │   ├── Detail
│   │   │   ├── __init__.py
│   │   │   └── form_template.yaml
│   │   ├── List
│   │   │   ├── ItemTemplate1
│   │   │   │   ├── __init__.py
│   │   │   │   └── form_template.yaml
│   │   │   ├── __init__.py
│   │   │   └── form_template.yaml
│   │   └── __init__.py
│   └── Navigation
│       ├── __init__.py
│       └── form_template.yaml
├── server_code
│   ├── Exporters
│   │   ├── Excel.py
│   │   ├── GoogleDrive.py
│   │   └── __init__.py
│   └── Importers
│       ├── Excel.py
│       ├── GoogleDrive.py
│       └── __init__.py
└── theme
    ├── assets
    │   ├── standard-page.html
    │   └── theme.css
    ├── parameters.yaml
    └── templates.yaml