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


Raspberry Pi 4: Finally Fast Enough for a Web IDE
24th June 2019

The $35 Computer is All Grown Up

I woke up this morning to a delightful surprise – the Raspberry Pi 4 has launched, nearly a year ahead of schedule! It’s a massive upgrade on previous versions of the Pi, with a much beefier ARM processor – from the relatively simple in-order A53 on 40nm silicon, to the superscalar A72 at 28nm, giving 2x-4x speedups, depending on the benchmark. Raspberry Pi are claiming “desktop-like” performance, so I had to find out – is it fast enough to use as a web development platform?

These days, a lot of popular development tools are built on web technology. Anvil is no exception – it’s an environment for developing full-stack web apps with nothing but Python, and it’s all in the browser. It’s got a drag-and-drop UI designer, a Python code editor with code completion… it’s a great test for whether the Pi is ready to use as a dev platform.

We’re based in Cambridge, home of Raspberry Pi, so I cycled by their shop on my way to work and tried it out. I am pleased to report that the Anvil code editor runs delightfully on the Pi, even with only 1GB of RAM. I, um, may have got a bit excited…

Building a live data logger and viewer

Of course, I had to buy onetwo, and see what I could do with them. It’s a pretty muggy day for England, so I bought a SenseHAT and decided to graph the humidity in our office.

Here’s my app, developed entirely on the Pi. I built the UI in Python with Anvil, and the data is being recorded into Anvil’s Data Tables by an Uplink script. Take a look:

Here’s the source code for that web app:

Open source code

And here’s the script I’m running on the Pi to record the data:

import anvil.server
from anvil.tables import app_tables
from sense_hat import SenseHat
from datetime import datetime
import time

sense = SenseHat()

anvil.server.connect("[INSERT UPLINK KEY HERE]")

while True:

Want your own? Of course you do! Go buy a Raspberry Pi 4!

New: Easier Integration with Microsoft Services
13th June 2019

Connecting Anvil apps to Azure AD

Anvil now has built-in integration with Microsoft Azure Active Directory, for all Business Plan users.

You can allow users to sign into your app with their work, school or personal Microsoft account with a single line of code:

If you’re using Anvil’s Users Service for login, you can just check a box - no new code required!

Sign-in methods supported by the Users Service: Email&Password, Google, Facebook, Microsoft Azure, Local Active Directory, Client Certificates (PKI).

You can link your Anvil app more tightly with your Azure or Office 365 subscription, by connecting it with your Azure Active Directory tenant. This lets you build apps that use the Microsoft Graph APIs to interact with Office 365 and other Microsoft services.

You can also restrict your app to only accept, for example, users from your organisation.

Restrict which accounts can log in

If your organization uses Azure Active Directory to manage user accounts, it’s really easy to limit your app to users within your organization:

Radio button list from Azure AD Portal showing the account types you can restrict auth to (your org, all orgs, all MS accounts).

Here’s a step-by-step guide to setting up the Azure Portal to talk to Anvil.

Access Microsoft APIs from Anvil

Microsoft has a whole universe of APIs, allowing you to do anything from automating emails in Outlook to driving Excel spreadsheets.

You can get an access token like so:

token =

and use it in an HTTP request to access a Microsoft API:

me = anvil.http.request('',
                        headers={'Authorization': 'Bearer ' + token}, json=True)

That’s a request to get everything Microsoft knows about me - not much, fortunately!

{'@odata.context': '$metadata#users/$entity',
 'businessPhones': [],
 'displayName': '',
 'givenName': '',
 'id': 'eeecf79b-ae39-48d3-8c6b-670f8d6a8f59',
 'jobTitle': None,
 'mail': None,
 'mobilePhone': None,
 'officeLocation': None,
 'preferredLanguage': None,
 'surname': 'anviltest123',
 'userPrincipalName': ''}

Read the tutorial to learn more

To learn exactly how to use Anvil’s Microsoft integration, follow the tutorial:

  Read the tutorial

Python in the browser: How does it work?
4th June 2019

What powers Anvil?

Our mission is to bring sanity to web app development. Anvil lets you build web apps with nothing but Python – and this means running Python in the browser as well as on the server.

This lets us replace the many technologies of the Web stack with something more coherent:

Two diagrams of the web stack, how it is now with a disjointed set of technologies, and how it is in Anvil with everything in Python and connected by function calls

There are several implementations of Python that run in the web browser, and Yasoob invited me to survey some of them for Python Tips.

I compare Skulpt, Brython, PyIodide, Transcrypt, PyPy.js and Batavia. I then talk about why we chose Skulpt to build Anvil – and why it’s not enough simply to replace Javascript with Python.

For the full story, read the article on the Python Tips blog:

Read the article
Want to know more?

Running Python in the browser is only part of what makes Anvil so powerful. To see the rest – including drag-and-drop user interfaces, built-in databases, and tight integration between client and server code – check out our introductory tutorial:

Introduction to Anvil

Stories from the Workshop #1: Telemix
20th of May, 2019

Listen to this audio episode:

Download MP3 Subscribe via iTunes
Introducing our new audio series

People use Anvil for amazing things. We’re constantly surprised by the variety, and the more we talk to people using Anvil, the more we learn! So we’ve decided to start recording some conversations with Anvil users: We’re calling them Stories from the Workshop.

In this series, we’ll be hearing everyone from data scientists to startup founders, and – in this case – telecomms experts.

Episode 1: David Wylie, Founder of Telemix

Have you ever wondered how TV phone-in numbers actually work? Or how ingenious telephone fraud really is? We asked David Wylie. David has worked in telecoms for his entire career, from the early days of digital telephony, through mobile phone ringtones, premium SMS, and more. He founded and runs Telemix, a number broker and hosted telephony supplier.

Meredydd sat down with David to hear some stories from a career in telecoms, learn how Telemix helps governments protect against international dialling fraud, and talk about how Telemix uses Anvil to build and deploy their applications.

Overthinking T-Shirts with SciPy
6th of May, 2019

Statistically Modelling Conference Swag at PyCon 2019

Sponsoring a conference has many challenges, and one of them is making sure you don't run out of T-shirts!

In his popular lightning talk at PyCon 2019, Meredydd described how we use SciPy to model the distributions, and minimise our chances of running out:

(Scroll down for a transcript)
Anvil logo
For more information about Anvil, check out

Hi! My name is Meredydd, and I run a startup called Anvil. We make tools for building full-stack web apps with nothing but Python, and we are sponsoring PyCon again this year. It's great to be back!

Like any good sponsor, we give out T-shirts — specifically, to anyone who builds an app with Anvil and shows it to us at our stand.

There are two problems with this. For one, Cleveland is a long way from home, and all these T-shirts have to come with me in a very heavy suitcase.

Problem number two: Python developers, it turns out, come in many different shapes and sizes. Pictured here are two Python programmers: a shirt that fits the one on the left is going to look pretty undignified on the one on the right.

So, the question is, “how many shirts should we be bringing of each size?”

We've been here before, so we could just bring twice as many of each size as we gave out last year.

Last year, we gave out two women's-cut extra-small shirts, so perhaps we should bring four this year. That seems plausible.

But last year, we gave out 27 men's large shirts. If we brought 54 of them this year, that would definitely be overkill.

If you think about it, that 54th men's large shirt is much, much less likely to get used than that 4th women's extra-small.

It's the Law of Large Numbers: If you've got a larger sample size, it will average out more reliably.

We can model this with a binomial distribution. Imagine we're rolling 3,500 dice — one for each person at PyCon — and then counting up how many rolled "Men's Large".

from scipy.stats import binom
def get_dist(n_attendees, prob):
  return [binom.pmf(k, n_attendees, prob)
          for k in range(n_attendees)]

Thankfully, SciPy has a function for calculating this distribution, and so I'm going to use it to write an interactive tool for exploring this distribution.

I'm going to write a function that gets the probability distribution for a given number of attendees, and a given probability of each attendee claiming a particular size of shirt.

At this point, the live-coding begins. Open the source code to follow along:

Copy source code

Now we have our distribution, we can make an interactive tool to explore it.

Our user interface will have a text box where we can enter how many of this size of shirt we used last time; and then underneath it will be a plot so we can explore the distribution.

def text_box_1_pressed_enter(self, **event_args):
  """This method is called when the user presses
     Enter in this text box."""

  dist ='get_dist', 3200,
            int(self.text_box_1.text)/3200.0) = go.Bar(y=dist)

When you hit Enter in this text box, we're going to call that `get_dist()` function we defined earlier. The number of attendees is 3,200, and we can estimate the probability from the number we gave out last time, because that was also out of a population of 3,200

Once we've got that distribution, we can plot it as a bar chart.

When we plot the women's extra-smalls, the distribution is actually quite wide. Of course, we're most likely to need two shirts, same as last time. But we could easily need twice that number, or even more.

Whereas if we check out the men's large shirts, the distribution is a lot tighter. Still, again, most likely to need 27, same as last time, but we're vanishingly unlikely to need twice that number.

return binom.ppf(0.95, n_attendees, prob)

Now, we've constructed a statistical model that can actually answer our question. We want to know how many shirts to bring, to avoid running out.

What we want to do is to find a number of shirts such that there is a 95% probability of needing that number or less. This is the 95% point of the probability distribution, and SciPy provides a function for calculating this: `binom.ppf()`.

So we calculate the 95% point for the probability distribution of every size of shirt, and that's how many shirts we bring.

We wire this up in the UI, to display the number of shirts.

We see that for the women's extra-smalls, we need 5 shirts -- more than double the number we gave out last year -- to be 95% sure of not running out.

Whereas for the men's large shirts, we need 36 -- that's only 33% more than last time.

You can get the source code of the app I've just built here:

Copy source code

And if everyone in this hall comes to our stand, builds an app, claims a T-shirt, and completely cleans us out?

Well, at least that'll show the statisticians. Thanks very much!

Learn More

Get the best out of Anvil with our free email course.