DEV Community

Cover image for Getting Started with Anvil for Python
Bas Steins
Bas Steins

Posted on • Originally published at bas.codes

Getting Started with Anvil for Python

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
Enter fullscreen mode Exit fullscreen mode
  1. If you want to use Anvil's plotting functions, which depend on the plotly package, install this with pip
pip install plotly
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

You can start the Anvil server with

anvil-app-server --app MyTwitterStats
Enter fullscreen mode Exit fullscreen mode

Then head over to localhost:3030.

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.

Top comments (1)

Collapse
 
drop91452037 profile image
Drop

Test