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


Talk Python's Mastodon Michael Kennedy's Mastodon