#100DaysOfCode in Python Transcripts
Chapter: Days 85-87: Fullstack web apps made easy
Lecture: Anvil concepts
0:00 Let's review some of the core concepts around Anvil.
0:02 We saw that we start be defining these forms.
0:05 We drag the components over, we set their properties,
0:07 their names, their bindings, all that kinds of stuff.
0:09 Here's our add document UI and we also have the code,
0:13 so on the flip side we could look
0:15 at the code behind in the form
0:17 and hook into the events for like
0:19 the button click or link click
0:21 or page load or this thing shown
0:23 all sorts of cool tuff.
0:25 And this Python code is actually converted
0:31 So all the code you write here
0:32 doesn't ever touch your server at all.
0:34 It's just, we write it in Python
0:36 but it actually runs locally
0:38 which is actually really amazing
0:39 and takes a lot of the load off your server.
0:41 One thing we wanted to do was navigate between sub forms,
0:45 so to load a different sub form
0:47 but effectively in this case
0:48 navigate the home_details_form.
0:50 We go to the content panel
0:52 and clear out whatever happens to be there
0:54 and then we add a new instance of
0:56 the sub form that we want to show.
0:58 Sometimes it's parameterless like this one,
1:00 other times like our document details
1:02 we actually passed in the
1:04 particular document that was selected
1:07 and then it showed the details of that.
1:08 It's a really really nice way to navigate between these.
1:12 Of course you're going to likely need a database.
1:15 You can go to the data table service
1:17 and create these tables and fill them up with data.
1:20 It's really easy, you can even link between them.
1:22 Don't forget to set the permissions,
1:26 but on the server side there is access.
1:30 To do that server side code,
1:31 we're going to write a server module
1:33 and make it callable back on the client
1:35 so here we created all docs method
1:37 and we added a callable decorator,
1:40 we just write whatever code we want and return it
1:42 and this magically finds its way back
1:44 linked in with all sorts of auto complete
1:46 in various places back on the client side code.
1:50 Speaking of client side code,
1:51 here's a little bit of our refresh data
1:53 we just say anvil.server.call and we type in the name
1:56 and then we put in the perimeters
1:57 if they're more after that.
1:59 Now we just work with the documents, right?
2:01 So it's just a list of dictionary's, off we go.
2:04 Once you get your app built,
2:05 you want to put it on the internet.
2:07 It's so amazing.
2:08 So you can click publish
2:09 and it pulls up either a little trial link,
2:11 you want to try the mobile version on your phone
2:13 or I clicked share via public link.
2:17 We also saw that there's version history
2:19 which is really nice, you can clone that with git
2:21 but what's relevant here is you can click publish
2:25 at the different save points.
2:26 So you name these like to present,
2:28 that's one I named
2:29 and if for some reason you make
2:30 a new change you don't like it
2:31 just go click publish and instantly
2:33 roll it back to an old version.
2:34 Really awesome, right there.
2:37 Finally, if you want to get the whole story, the back story on Anvil,
2:39 I had Meredydd Luff on Talk Python
2:42 on Episode 138 and we talk about all the
2:44 internal workings of how this is built,
2:47 how he makes all the pieces work together
2:50 and it's pretty cool.
2:51 So if you enjoyed this and want to learn more,
2:52 check out that episode of Talk Python.