All Articles

Getting Started With Anvil

Anvil is a runtime for Python code. What makes it special is that it helps you create browser based applications with just Python code. No HTML, no JavaScript, just Python.

The best thing is that Anvil is an open source project, so you can get started for free.

Even better, you can sign up at anvil.works for free, too. The hosted Anvil version gives you an in-browser IDE.

Installing the Open-Source Version Locally

  1. Install Java. Anvils runtime server needs to run a Java JAR. You can download Java directly from Oracle.
  2. Install the Open Source Version of Anvil with pip:

    pip install anvil-app-server
  3. If you want to use Anvil’s plotting functions, which depend on the plotly package, install this with pip

    pip install plotly

Testing the first app

Once you have installed Anvil and its dependencies, you can create an example app based on the todo-list template which comes bundled with your Anvil installation:

create-anvil-app todo-list MyTwitterStats

You can start the Anvil server with

anvil-app-server --app MyTwitterStats

Then head over to localhost:3000.

It should display a Todo-App in your browser. If that’s the case, you have successfully installed Anvil and ran your first app.

Note that the open source version is just capable of running Anvil apps. The hosted service offers you a browser-based development environment on top.

Using the Hosted Anvil Service

If you want to use the in-browser IDE of Anvil, you have to sign up for their service on anvil.works.

Anvil Drag and Drop Editor

This gives you an easy to use drag-and-drop editor for your UI as well as a full-featured IDE for your code. Technically, the runtime is the same as the open source edition.

Note that the free version of anvil.works comes with some limitations. For example, usage of the azure packages, the standard library’s lxml, and gzip are restricted. However, the Paid Plan of Anvil does not impose these restrictions, plus you can work around these restrictions by providing your own uplink Python runtime.