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.

Blog - Page 5

Simple Object Storage
3rd of May 2018

New: Store richer data in Data Tables

Do you find yourself wanting to store more than just strings, numbers and dates in your tables? Perhaps you have complex records with dynamic fields, or perhaps you want to store lists of data without making a whole new table.

Today, we’re introducing a new type of column: the Simple Object. It can store lists, dicts, numbers, strings and (of course) None. (If you’re familiar with JSON, you’ll know this is another way of saying “any JSON value”.)

Add a Simple Object column to your table like this:

Creating a Simple Object column

Now you can store structured data in a single row of your table:

  app_tables.people.add_row(
    name = "Kermit the Frog",
    contact_details = {
      'phone': [
        {'type': 'work',
         'number': '555-555-5555'},
        {'type': 'home',
         'number': '555-123-4567'}
      ]
    })

Querying them is just as simple. If you supply an object to the Data Tables search() or get() method, you’ll match every value that contains those values, dictionary keys or list items. Here’s an example:

  def get_person_for_number(phone_number):
    # We have a phone call for this number. Who is it?

    return app_tables.people.get(
        contact_details = {'phone': [{'number': phone_number}]}
    )

You can read more about Simple Object columns in the Data Tables reference docs.

Anvil News - March
27th of March 2018

Hi everyone,

A lot has happened in Anvil in the last month, here are the highlights:

1. Building Y Combinator Startups in Anvil

How fast can you build a startup? We built full, working versions of two startups from the famous incubator - in just an hour or two each. See how easily you can build a startup with Anvil:

2. New Learning Centre

We’ve reorganised the Anvil documentation, and added a bunch of new how-to guides to our “Cookbook” section. Did you know…

Find all these and more at anvil.works/learn.

3. Do more with Anvil

We’re always making Anvil better. Here are some little improvements you might not have seen:

  • We’ve made it even easier to download files from your Anvil app. You can set the url property of a Link component to any Media object, even a temporary one.

  • Two-factor authentication - secure your access to the Anvil IDE by enabling two-factor auth on your account today. (Open the Anvil editor and choose My Account)

  • The Client Uplink lets you connect un-trusted code to your Anvil apps, just like the Uplink. Building the Internet of Things just got easier! (Read the docs)

  • Customise your Stripe credit card form - you can now set an icon_url with anvil.stripe.checkout()

4. Show and Tell in the Anvil forums

See what other people have built, and share your own apps, in the Anvil forums. Ask questions, get help, and get inspired.

I look forward to seeing you there!

YC Prototypes #2: Building Magic in 2.4 hours
23rd of March 2018

Day 2: Let’s make Magic (YC W15)

It’s Y Combinator’s week of Demo Days, and we’re prototyping one YC startup each day. (If you missed it, check out the first in this series, where we prototyped an e-parking service in an hour and a half.)

Magic (YC W15) is an SMS concierge that can do anything. Text them a request, however outlandish, and they will make it happen. Let’s put ourselves into the founders’ shoes, when they were just starting out. We don’t know if anyone wants this service, so we need a working product they can use. What do we need to build?

  • We need to see and respond to texts from our customers.

  • We need to charge customers for the things we provide (with a commission, of course). They shouldn’t need to enter their credit card every time.

  • We need to share this work between several people.

With Anvil, it turns out we can build this all in a couple of hours. Watch me build a fully working product in this time-lapse video, then scroll down for the play-by-play:

1. Two-way Conversation (45 mins)

We use Anvil’s built-in data tables to store customers and events (messages, notes, etc), and build pages to display them. We use the Users service to authenticate operators (ie us).

Within half an hour, we’ve got the basics: We can receive SMS using an HTTP endpoint from a service like Twilio, display the conversation, and send replies.

2. Take Payment (45 mins)

Now a customer can ask for something, we need them to pay for it! To make purchases truly frictionless, we’ll take their credit card once, then keep it on file for anything they need in the future.

Anvil’s Stripe support makes this simple. We make an app to collect the customer’s card details, and then we send them a link to open that app on their phone:

After that, the card is on file, and we can charge them at the click of a button. (We also note our profit margin for future reference.)

3. Coordinate many operators (50 mins)

If this app takes off, we’ll need help. We don’t want any messages to fall through the cracks, so we text all our operators when a new customer arrives. But we don’t want to notify every operator about every message – they’ll get drowned!

Instead, let’s track which customers need attention, and let operators “claim” customers. (We make sure two operators can’t claim the same customer by accident.)

The operator can mark a customer as Done (request resolved, no longer needs attention), or Can’t handle (still needs attention – “un-claim” the customer and text other operators for help).

If we need more information from the customer, the operator can select “Tell me when they reply”. The operator can go do something else: when the customer replies, we send an SMS to this operator only.

Prototype Complete (2 hours 20 minutes)

We’ve built the infrastructure for an SMS concierge in just a couple of hours. We can help people by text, take payment, and even coordinate a large team of operators if it suddenly gets popular. It’s a fully-working product that can take revenue right away, and scale as we grow.

Here’s how our final app works:

You can grab the source code yourself – click below to open the apps in the Anvil editor:

Copy Apps

Want to dig into how these apps work? Our tutorials show you all the pieces these apps are made from, and more.

How We're Building One Y Combinator Startup a Day
20th of March 2018

Prototyping a YC Startup Each Day

Check out Part 2 of this series >

It’s Y Combinator’s Demo Day this week, when the startup incubator’s graduates show their products to the world. To mark the occasion, we decided to try a challenge: How much time does it take to prototype a startup?

For each Demo Day this week, we’ll build a working prototype of a startup from a recent YC batch. “Working” means more than a landing page – we want enough technology to provide the core service to the customer, and to get paid for it.

Our secret weapon is Anvil. It’s a platform for building web apps without the fuss: it’s got a visual interface designer, client- and server-side code is all in Python, and it deploys to the cloud with one click.

We’ll walk you through the design process, show you some screenshots, and give a breakdown of how long each stage took. Today, we start with:


1. Meter Feeder (YC Winter 16)

Build time: 1 hour, 30 minutes.

We’re moving to a cashless world, but urban infrastructure is slow to change. Meter Feeder lets you pay for parking with your smartphone, without costly new infrastructure.

Imagine we’re the Meeter Feeder founders: We need to build a working prototype that we can demonstrate to a city government, and deploy as a proof of concept. This means:

  • The public (customers) need to be able to pay for their parking.

  • Traffic wardens on patrol need to know whether a car’s parking has expired.

Let’s fire up Anvil, and see what we can do.

Design the data model (10 mins)

We’re going to break up parking into “locations”. We’ll identify a location with a number, which can be entered easily on a phone keypad, and displayed on legacy parking infrastructure (translation: put a sticker on the physical parking meter). Each location has a cost for a given unit of time, and a maximum stay (eg “$0.50 per 15 minutes; max stay 2 hours”).

We then create a table of “bookings”, which represent payment for a car to park in a location. Finally, we add user records (with Anvil’s built-in user authentication), and link each booking to the user who made it.

This is all pretty quick to set up with Anvil’s Data Tables:

Design the public interface (30 mins)

Collecting payment is pretty straightforward with Anvil’s Stripe integration. Collecting the registration plate number and parking duration is even simpler. But parking your car is a frequent event, and we don’t want to make the customer re-enter this information every time. What’s more, after a user has paid for parking, they’ll want to check back and see how much time they have left.

So the first thing we do on app load is trigger the login/signup screen. (We use the “Remember me” option, so regular users never have to see it again.) Once we’re logged in, we can find and display your recent bookings. We also offer a quick “park here again” button to repeat an expired booking.

If you choose “New Booking”, we prompt you to enter a location code, or pick from a list of locations you’ve booked recently.

The next screen has big touch-friendly buttons for choosing your time and entering your registration. If there is a Stripe record associated with your account, we show a “pay with the same card as last time” button.

Thanks to the “Park here again” button on the first screen, a returning user can park somewhere they’ve used before with only two touches.

Back-end Logic (25 mins)

This is the back-end to make all those buttons work. This ends up being a 60-line server module, exposing four functions - “get my recent bookings”, “get a location record for this number”, “get the last licence plate I parked with”, and “pay for parking”.

Wiring these up to the front end didn’t take long, because Anvil lets you return live database rows into client code, and then use data bindings to display them in the UI.

Enforcement App (15 minutes)

After all that, the enforcement app came together pretty quickly. It’s a private app, so we can skip the user authentication and make the Locations and Bookings tables readable directly by client code.

When a parking warden arrives at a new location, they can enter the location code to display all valid bookings for that location. We also support as-you-type searching by licence plate number, so they can query a single plate in a busy location.

That’s all, folks! (1 hour 30 minutes)

We’ve built a working, deployable prototype of the MeterFeeder service, in an hour and a half. If we were the MeterFeeder founders, we’d be feeling pretty good by now - we’ve got a compelling demo, without spending weeks or months getting this far. This means we can move straight on to the hard part: selling the concept to local government.

You can see the source to these apps yourself – click to open them in the Anvil editor:

Copy Apps

Want to dig into how these apps work? Our tutorials show you all the pieces these apps are made from, and more.

Live Coding a Stock Portfolio App
31st of January

Overview

In this live-coding video, you will watch me prototype a financial "Software as a Service" (SaaS) application in under an hour. At the end of this video, we will have an application for tracking stock prices. It has user accounts, per-user portfolios, and a monthly credit-card charge for using the service.

Follow along as we start from a single stock chart and build up to a full subscription service. You can also copy the source code and explore it yourself:

Copy source code
Copy source code

Learn More

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