Skip to content
Generic filters
Exact matches only

An Introduction to Anvil — Full-Stack Web Apps with Nothing but Python | by Robert Ritz | Aug, 2020

Build a data science app in minutes, and deploy it to the web in one click.

Robert Ritz

Disclaimer: I’m not affiliated with Anvil, I just love their product.

As more data scientists enter organizations around the world, most will find a very different work environment than what they may have dreamed about at Netflix, Facebook, or Google. At these companies, data scientists are supported by data engineers, machine learning engineers, application developers, and dev-ops specialists. Instead, they will probably find themselves working in a small team, or even by themselves. This poses major issues when a data scientist wants to get their insights, models, and even products out of Jupyter and into production.

Anvil fills in these gaps by allowing you to build a full-stack web app using only Python. You can build a user interface with a simple drag and drop UI (or build it with code if you insist), plot with your favorite Python plotting library (Plotly, Matplotlib, etc.), and then deploy to the web in one click. No servers or containers to deal with.

Let’s take a look at the basic features of Anvil to see how powerful it can be.

Easily build your UI with a drag and drop interface. Elements like dropdowns, sliders, images, and text are easy to position, no HTML or CSS required.

Visually position elements to get the look you want.

You are not locked down to a specific UI. You can position elements to work for your use case. When you have the look you want, you can connect them all together with Python.

A dropdown can have its options predefined or created in code. Not just dropdowns though. Every element is accessible in Python.

Often a large part of your app will be sharing insights through data visualization. Anvil supports plotting from nearly every popular Python plotting library. Here are the libraries that Anvil has made guides for:

  • Matplotlib
  • Plotly
  • Seaborn
  • Bokeh
  • Altair
  • Pygal

Plotly has the most direct support due to its front-facing Javascript library, and it’s the library I choose to use. For others, the plots can be displayed by embedding HTML or even an image file. Check out the Anvil plotting guide.

Simply drag the chart element onto the page, then connect it with Python. A simple bar chart can be made with the following code:

Often you will want to store some data for your app. If you or your organization has a database, then no problem. Anvil supports external databases through popular Python libraries like pymysql and psycopg2.

But a feature I have found to speed up my development, even more, is the integrated databases that Anvil apps have. Called Data Tables, they are PostgreSQL based database system that you access directly in Python.

When you are ready to deploy your app, there is no need to worry about how to get the app off of your local machine. It’s already in the cloud! Simply publish the app with one click and share the link. If you want to secure the app you can easily authentication by adding users.

Deploying takes just three clicks and you have a public link to share with the world!

There are actually several ways to deploy your app:

  • Build and deploy in Anvils cloud — Probably the easiest and fastest method, but this may not be perfect for everyone.
  • Build and deploy on your private cloud — Anvil has an Enterprise version that allows you to deploy the full Anvil stack on your own servers.
  • Build with Anvils IDE, host on your own server — This gives you the great drag and drop features, but allows you the freedom to host wherever you want. See below for the open-source app server.
  • Build from scratch with a text editor — You will miss out on pretty much everything that makes Anvil faster, but it’s possible.

Perhaps you are the type of person that wants to control the app from top to bottom, and not rely on a specific vendor to host your app. Well, Anvil has you covered there as well. Anvil has open-sourced its app server, which allows you to host your Anvil built apps nearly anywhere.

Personally, I still prefer to use Anvil hosting, as it is by far the easiest and most convenient way to host apps.

Developing a web app with Anvil is 7x faster than using current tools. This sounds like a marketing line, and it is, but it’s absolutely true. I tried developing an app with Dash and within a week I wanted to throw my computer out the window. Here is perhaps a better description of how you should look at Anvil:

Using Anvil with a team of 1 or 2 you can do the same work faster than with a team 4 or 5.

One of the best things about Anvil is the great community. On the Anvil forums, you will find a great group of welcoming developers to help you get started and answer questions. There is also a great Show and Tell section where you can get great inspiration for your own projects. Here are some great apps made with Anvil:

I’ve used Anvil for almost a year now and I can’t imagine using anything else to show my data science ideas to the world. It is constantly improving, the community of developers is excellent and supportive, and it is simply a joy to work with. Check it out at

Robert Ritz is a Data Scientist and educator based in Ulaanbaatar, Mongolia. He can be reached at [email protected]