Anvil: Web apps with nothing but Python Transcripts
Chapter: Application first steps
Lecture: Anvil building blocks

Login or purchase this course to watch this video and the rest of the course contents.
0:00 The last thing I want to talk about
0:01 before we actually start building our application
0:04 is the Anvil building blocks.
0:06 Let's just take a moment and get a broad picture
0:09 of what things we have to work with.
0:11 I showed you the Legos before and said it's fun to click
0:14 the Legos together.
0:15 Well here are some of the Legos we can work with.
0:18 We look at Anvil there's different core concepts
0:22 and functionality that we can bring together
0:24 to build our application.
0:26 Probably the most obvious and in-your-face and front
0:29 and center type of thing is what are called forms.
0:32 These are basically the web pages.
0:35 There's nice visual design here, you drag and drop
0:37 and you arrange all our your UI elements.
0:40 Here's a label.
0:41 Here's a repeating layout of repeating bunch of rows.
0:45 Here's a chart.
0:46 Here's some inputs in a button and so on.
0:49 These are your forms.
0:50 We're also going to have something that are called modules.
0:53 I want to emphasize that they are client modules as opposed
0:56 to something similar called server modules.
0:59 Now we can write Python code to control our forms
1:02 to respond to the button click events and so on.
1:05 We can write other code in a separate file
1:09 conceptually a separate file.
1:11 In these modules that we can use across forms.
1:15 It's not a good design pattern to cram all your code
1:18 into the button click event.
1:19 You really often want to separate
1:21 that have like a data access layer
1:23 maybe a navigation layer, other types of things.
1:27 We're going to put that into these things
1:29 probably called
1:30 client modules sometimes into server modules.
1:33 So what's the client server bit about.
1:34 Well incredibly this Python code that we write
1:37 the forms and for the client modules
1:40 we're going to write standard Python code.
1:43 This actually runs in the web browser.
1:46 Its converted to JavaScript, it's so awesome.
1:49 So this lets us not have to write JavaScript
1:51 but to write Python for interactive client side code.
1:55 Just like you would with say VueJS or something like that.
1:59 But with Python and a nice visual designer instead.
2:02 That's the client part.
2:03 But sometimes we want to write code that runs on a server
2:07 it's protected from the users messing with it
2:09 because of course you got access to the web browser
2:11 you can mess with the JavaScript.
2:13 We want to write on the server we want to talk to the database
2:15 maybe call other services
2:17 use things like API keys and so on.
2:19 So we can also write Python code that runs
2:22 on the server side in Anvil
2:23 and we can link these together really similarly.
2:26 So client modules and server modules
2:28 both great for breaking up our code and reusing it.
2:31 Sometimes that belongs on the server
2:32 sometimes it belongs on the front end
2:35 and we can write both of them.
2:37 We also have databases or Data Tables.
2:41 Most important web applications save data.
2:43 Almost all the dynamic ones do.
2:46 Few of them depend just on APIs but almost all of them
2:48 have their own database or own data access.
2:50 So Anvil comes with a prebuilt database server
2:53 that's deeply integrated into Anvil both the client
2:56 and the server can work with it in interesting ways.
2:59 So you're going to be able to create these different tables
3:02 with relationships and all that great stuff
3:04 so that we can go and query it and use it to store our data.
3:10 And then there are a bunch of other things
3:11 that I'm going to refer to as services.
3:14 So we might have user management
3:16 or encrypted secret data that we can work with.
3:19 Maybe we want to work with stuff over at Google.
3:21 Log in with Google or work with some of the stuff there
3:23 so we can interact with a Google API or Facebook API.
3:27 We want to add eCommerce to our site.
3:29 We want to charge credit cards.
3:30 Stipe is a great credit card provider service
3:34 that we can sign up for.
3:35 We can integrate say Stripe credit card charging options
3:38 right into our service.
3:40 Uplink is interesting.
3:41 This is a way to let our Anvil apps
3:43 call into other applications.
3:45 The example they give is there's a Raspberry Pi
3:47 running Python code.
3:49 It sets up a way like a bidirectional communication
3:53 back to Anvil
3:54 so that our Anvil app can trigger operations
3:56 over on the Raspberry Pi.
3:58 That's pretty incredible.
3:59 There's a bunch of others that we're not talking about
4:02 explicitly here.
4:03 Background service ability to send and receive email.
4:07 All sorts of cool stuff like that.
4:08 But I just want to give you a sense
4:09 there's all these little services that we can bring in
4:12 this extra functionality right into our application.
4:15 Well that's it.
4:16 Those are the building blocks.