Learn Python with Talk Python's 270 hours of courses

#224: 12 lessons from 100 days of web Transcript

Recorded on Monday, Jul 29, 2019.

00:00 Back in May of 2018, Bob Belderbos, Julian Sequira, and I started what would turn out to be a nine-month

00:06 project. We wanted to create a dedicated 100 days of code course specifically for Python web

00:12 developers. Much of what we created for that course, we did have prior experience with,

00:17 but with that many different topics, much of it was also new to us. On this episode,

00:22 we teamed up to distill the lessons, tips, and tools we found interesting on that journey into

00:27 a quick list of cool tips and techniques. We hope you find something new and useful.

00:31 This is Talk Python to Me, episode 224, recorded July 29th, 2019.

00:36 Welcome to Talk Python to Me, a weekly podcast on Python, the language, the libraries, the ecosystem,

00:55 and the personalities. This is your host, Michael Kennedy. Follow me on Twitter where I'm at,

01:00 M. Kennedy. Keep up with the show and listen to past episodes at talkpython.fm, and follow the

01:05 show on Twitter via at Talk Python. This episode is brought to you by Ting and Linode. Please check

01:10 out what they're offering during their segments. It really helps support the show. Bob Julian,

01:14 welcome back to Talk Python to Me.

01:16 Thank you.

01:16 Good to be here, Mike.

01:17 Nice to be here.

01:18 Yeah, it's good to have you both here. We kicked off our acquaintanceship way back. I can't remember

01:24 which episode it was. It was quite a while ago when we talked about this 100 Days of Code project

01:29 and journey that you all had been on. And actually, it's turned out to be quite the journey from there

01:36 as well, right?

01:36 Oh, yeah. Just nonstop. I think it was episode 140 as well.

01:40 Yes, it was 140. Thank you.

01:42 100 Days Survivors. It was quite a hardship.

01:46 Yeah. So, back then, you guys had been going through 100 Days of Code and documenting it and

01:51 blogging about it. And then, you know, you came on the show to talk about it. And after that show,

01:56 we were sitting around talking like, you know, this is really cool. There's not a whole lot to support

02:00 people specifically in Python to do it. So, you guys and I, we all teamed up to write the 100 Days

02:06 of Code course that we released last year. And that was really fun and people seemed to like it. So,

02:12 we wrote the 100 Days of Web in Python course. And that was quite the journey as well and recently

02:19 released that. So, this show is going to be based on stuff that we take from those experiences.

02:26 And I want to be clear. I don't want this to be just like an infomercial about the course. I want

02:30 us really just to focus on the technology. But when we created these courses, this is like,

02:36 it took us nine months to write that 100 Days of Web course. And some of that was just the effort of

02:40 recording. But a lot of it was research and polishing ideas and like understanding things better,

02:45 right?

02:45 Oh, without a doubt. The amount of tech that and skill that I had to develop in order to teach it

02:52 was insane. There were so many topics that I just, I knew a tiny bit about, but not enough to actually

02:59 build something usable and something I could teach. So, yeah, a lot of that time, I would say 80% of that

03:05 time was actually learning and trying to figure stuff out.

03:07 Yeah.

03:08 Bob?

03:08 And there were some very big topics like JavaScript and Django. And we had to break them down in four

03:15 day segments, which was a challenge in itself.

03:17 Yeah. Well, I think part of the challenge of anything like this, and especially the web,

03:22 is I don't really know when this tipping point occurred, but it felt to me like for quite a while,

03:28 it was pretty straightforward. There were some choices you had to make if you wanted to write

03:32 a web app in Python. Like, am I going to use Django? I'm going to use Flask. Maybe I'm going to use Pyramid

03:38 like Michael. I really like that framework still. And now, now you look at the list of like new and

03:46 upcoming frameworks. There's like a new web framework every month, at least. It's crazy. So, you know,

03:52 it's not a surprise that we don't know all these off the top of our head because it's hard to keep up

03:57 with all of them. And then there's always the, well, that's only been out for a month. Like if I learn it,

04:01 is it going to actually be around like two months from now? Right. So it's, there's just,

04:05 do you guys get the sense that the web is kind of blown up? And then, you know, that's only the

04:09 Python framework, right? We've got JavaScript, we've got databases, we've got like, there's a lot

04:13 of axes on which that happens. That's exactly right. I hit the, I actually hit that issue recently at

04:17 work where, you know, I'm trying to create a web app, but did I use Flask or was I going to use,

04:22 you know, Django? And then wait, what sort of interaction did I need on there? What sort of

04:28 JavaScript do I need to learn? Oh, wait, do I need jQuery? You know, it just, the list went on,

04:33 you know, how am I going to deploy it? Is it going to be a static site? And yeah, it's just,

04:38 it's ridiculous, but it means there's a lot of fun to be had. That's right. There's a ton of fun to be

04:43 had. And so when we went through this course, we all learned a bunch of stuff. And basically it's made

04:48 up of roughly 24 four day little projects. And each one of them is generally a separate technology and

04:56 generally standalone. And I said, I don't want this to be an epimertial about the course. So I want to

05:01 really point out that this is all, every bit of this is, we're going to talk about is in a GitHub

05:06 repository. And each section has its own little bit with its own readme. So if you want to go play with

05:11 that, the GitHub repo is open and free. And we'll talk about like where each one of these topics lives

05:16 in the GitHub repo. And I'll be sure to put that in the show notes as well. So with that in mind, Bob,

05:23 you want to kick us off with the first topic that you got out of the course that you think is

05:27 interesting for Python web devs? Yeah, sure. And I start right off the bat with APIs and API star.

05:33 It's by the same author of Django rest. So I chose that framework as it's relatively new. And knowing

05:42 the author, I expected to have sensible defaults. And it had was a fun little project that makes it very

05:51 easy to build your APIs. I got pretty quick results. I also needed some test data for which I used

05:58 Macaroo, which is a service or website that makes it very easy to get fake data. And combining the two,

06:06 yeah, became an interesting project where I think I use some car data and build an API around it.

06:13 One of the challenges though, that I saw when we deployed the app is that there were some breaking

06:19 changes. So yeah, one warning when you use top notch open source off the shelf products that they might

06:27 change and they might change rapidly. So I think in the end, we had to pin the version in the requirements.

06:34 So to make sure that people weren't hitting those issues.

06:37 Absolutely. And API star is really cool. It's by Tom Christie. And it has changed a lot, actually,

06:44 even since, since we wrote the course. And that's, you know, that's just the way the way it goes.

06:49 That's what I was sort of hinting at not specifically thinking of API star, but there's a ton of these

06:54 projects that are like that. And, you know, I think it's good to do like a survey of all them out there. But it's

06:59 also challenging to figure out which one is going to gain the popularity and energy because they ebb and

07:04 flow. But yeah, it's really interesting. I love this the way that it works. One of the things that you introduced

07:11 me to here that I found super interesting is a great service for fake data. Because, you know, as a course

07:20 developer and trainer, having fake data is awesome, because you don't want to use real data, but you want to have

07:25 realistic data. But, you know, there's not that many trainers or course developers, right? But almost everyone has to have a

07:32 prototype app. And you often have to build the app before you have the data, because the app is going to collect the

07:37 data, right? And so in order to build out the UI and the API and all that stuff, it's really good to have

07:43 realistic data. So tell us about this place where you got the data from on that.

07:46 Yeah, it's muckerrule.com. And it has 143 data types, as we speak. And it's broken down in location,

07:55 commerce, advanced, personal, and the VIN number. And yeah, you just pop them in the field names,

08:12 and then you can download it in CSV, JSON, tab limited, SQL, Cassandra, Firebase, Excel, XML, like all

08:20 these useful data formats. And it generates a file. And then yeah, you can just load it in and start

08:27 using it. It's really cool.

08:28 Yeah, you named off some data types. And one of them was like car VIN, vehicle identification number.

08:32 And that's like this big, long, specific thing. But it literally generates reasonably valid looking

08:38 VIN numbers, not just random values there, but like actually what you would expect in terms of

08:43 number of character. Yes, exactly. And it has that stuff for like medical bits. And like,

08:48 it's really quite interesting, all the data sources that it pulled from.

08:52 Yeah, indeed. And if I look at the API class, then that literally translates to the data. So I have a car

08:58 class with ID, manufacturer, model, year, and VIN. So it made it relatively easy to build an API on top of

09:06 it. Yeah, that's cool. So if you're out there building something, and you need data for your API

09:10 or web app or whatever, Macro, that's pretty cool. And one thing I also wanted to highlight in this

09:16 section is PostPen. It's a GUI to test your API. So that's another thing. I used it before, but I guess

09:24 I became better at it because I had to use it again. And yeah, it's very convenient to test your API and

09:30 get and post requests from GUI. Yeah, you can do it from your dev tools. But Postman is so nice. It lets

09:38 you set the headers just right. It lets you do all the ACP verbs, you know, post, delete, things like

09:45 that. For Talk Python, I have a whole suite of APIs I have to maintain for most of the courses. And I have

09:52 a whole like segment of saved like development and production stuff in Postman for testing that and

09:59 make sure it all works. And yeah, I definitely recommend Postman as well. Yeah, awesome. All

10:03 right, Julian, you want to talk about this next one? Like I'm really excited about that. I just can't

10:07 believe how much we get out of this next one here. Okay, so I'm really excited about this one. This is

10:12 Netlify. Sounds a bit like Netflix, but it's Netlify. It was a static site generating deployment

10:21 website. It's just like a jack of all trades. I absolutely loved it. And the funny thing is,

10:26 as we touched on before, I knew nothing about this. I didn't even know it existed before this course.

10:31 As we were planning the course, you showed me this, Mike. You said, hey, if you're doing something on

10:36 static sites, check this out. Yeah, originally your goal was to just cover static sites. And like,

10:40 what do you use, Pelican or something like this? Yeah, Pelican. Yeah, that's right. And I go,

10:44 if you're doing Pelican, you got to check out Netlify because that looks super interesting.

10:48 And I thought, oh, what is this? What's this thing Mike's pointing me to? And when I went and checked

10:53 it out and actually had a go, it was fantastic. So to give anyone who's listening the general overview

10:59 is it's this amazing tool where you write your static site in GitHub as you normally would or whatever.

11:07 And once you have it built in there using Pelican or Jekyll or Hugo or whatever else you want to use,

11:14 you then point Netlify at your GitHub repo. So there is a little hook in there that

11:20 links into your repo and it just monitors your repo. It's this continuous delivery or continuous deployment

11:27 type tool where once it detects a change in your GitHub repo, it'll build your site for you

11:35 and deploy it on the net for you. So just completely hands off. You don't have to do a thing. And that was

11:42 probably one of the most satisfying parts of the course was when I was demonstrating that or recording it.

11:47 There was that moment of fear where I thought, oh, is it going to work? Please work. And then it just worked.

11:53 So as I'm recording, I generated the site. I pushed my GitHub code to GitHub and then it actually created the site within a minute.

12:02 And yeah, it's just, it's live up on the net. They give you a free URL.

12:07 So it's obviously some garbled rubbish that's your URL and you can obviously then go and purchase your own domain and add all that in.

12:14 That's all extra. But from a free base standpoint, you can run your static website on the net using Netlify.

12:23 And it was really cool. I really enjoyed it.

12:25 Yeah. It seems like just such a nice way to do things. To me, it feels kind of like what Heroku is to Python apps.

12:34 Like you can just get push Heroku and it takes your app and figures out how to run it.

12:39 Like Netlify is that for purely static sites.

12:42 Yeah, exactly right. So I think one of the most surprising things for me was going through the documentation on the website and just seeing how, I guess, fully documented everything was.

12:52 It actually tempted me because we use Pelican for PyBytes. That's our static site framework of choice for PyBytes.

13:00 So I was familiar with it. But once I got on the documentation and started going through it, I'm like, ooh, I want to try Jekyll.

13:08 Because I know Bob's mentioned that. He uses it for his blog. And then I've heard good things about Hugo.

13:12 And I just, there's this massive list that you can go through. And so if there's anyone listening to this that has a static site, I totally challenge you to give this a go.

13:23 Because it was one of the most satisfying things.

13:26 Yeah, it's super cool. And I can't believe what they offer for free, right?

13:30 I mean, just to be clear, we have no affiliation with Netlify. They didn't pay anything for this.

13:35 Just like, this is really cool. I can't believe that it's actually available.

13:39 Like, so custom domain, HTTPS certificates, continuous deployment through GitHub, all of that for free. It's crazy.

13:47 Yeah, it's a beautiful tool.

13:48 Awesome. Yeah, so if you've got anything static, that's definitely the way to do it. That's cool.

13:52 All right, so I guess I'm up next for the next one here.

13:56 One of the things I wanted to focus on was just foundational HTML.

14:00 Because I want to hear your two opinions on this.

14:03 Because to me, I for a long time didn't want to get into web development.

14:07 Because I knew I was a good developer, but I didn't feel like I was artistic in the graphical visual sense.

14:14 You know, like I was always like bad at art in school or whatever.

14:18 So I felt like I'm going to have a hard time designing stuff.

14:21 So HTML and CSS and all that like was until I took the time to sit down and properly learn it.

14:27 It was actually not a huge roadblock.

14:29 But so I'd always try to find like, what is the way I could do this without really writing HTML?

14:34 Like what little widget will generate the thing that I want to work?

14:37 Like the calendar, because I don't want to write.

14:39 You know what I mean?

14:40 Like that was me for a long time.

14:41 But then once I learned HTML and CSS super well, like it became this thing that I was happy to do.

14:46 And I felt like it was made like getting into this stuff much easier and took away all that hesitation.

14:51 So I thought it was great.

14:52 So I wanted to talk about like the history of HTML.

14:55 And there's just some stuff that surprised me there that I thought I would cover here.

14:59 So in the GitHub repo on days five to eight in there, there's a section where we go and recreate Yahoo.com and Google.com from scratch as they were in 1996.

15:14 That was cool.

15:16 It's cool.

15:18 But oh my gosh, can you guys believe what those sites used to look like?

15:21 Trash.

15:22 I don't want to know.

15:23 It's so weird.

15:24 I look back to 1996 websites and like, wow, it was really easy to actually create a web startup because like Google and Yahoo, we recreated the sites in 15 minutes or something, you know?

15:38 And it's just like, wow.

15:39 Yeah.

15:40 Really?

15:40 15 minutes.

15:41 Okay.

15:41 And now Google is a highly interesting technical foundation, but Yahoo is like a directory listing.

15:47 Like you could have finished it up in another hour.

15:49 I mean, it was really interesting, but that's all it was.

15:52 And so some of the things I found interesting as well is back in 1996, you couldn't use spreadsheets.

15:58 Spreadsheets.

15:59 Sorry, that's for style sheets.

16:01 Style sheets were not introduced until 1999.

16:04 Wow.

16:05 Wow.

16:05 I didn't know that.

16:06 Yeah.

16:06 All the HTML attributes had to just be set in the DOM, like over and over.

16:11 Yes, exactly.

16:12 Right.

16:12 Like you would for like a newsletter because they don't know that style sheets.

16:15 So that was crazy.

16:17 And then the other thing was, if you look at the history of HTML, like there was a lot

16:21 of rapid growth from 1990 to 2000.

16:24 There was a bunch of versions, you know, every couple of years or something like that.

16:28 In 1999 was HTML4.

16:32 In 2000 was XHTML, which is an attempt to make all HTML documents formal XML, like a superset

16:42 of XML.

16:43 So every element had to be closed.

16:44 Every attribute had to have a value with quotes for the value and things like that.

16:49 Right.

16:49 So that was 2000.

16:51 The next change to HTML was 14 years later.

16:55 So HTML didn't change for 14 years, even though this is like basically on the heels of the

17:01 dot-com boom and everything.

17:02 Like what happened there, right?

17:04 So in 2014, HTML5 came out.

17:07 Now I know there's probably like super minor little changes, but like no important changes

17:11 happened between 2000 and 2014, literally in the specification.

17:16 That's one of the things I actually kind of off topic, but what I love about this is that

17:21 you did all this research, discovered all this stuff, and then I got to go and learn

17:27 it through you.

17:27 So this is all cool stuff because, and I hate to say it, Mike, but you know, back in those

17:33 dates you were talking about, I was still pretty, I was still in school.

17:36 I'm sorry.

17:36 Well, you could have been one of those like kids that started a startup and dropped out

17:41 of middle school.

17:41 Could have.

17:44 No, just kidding.

17:44 Should have.

17:45 Could have, should have, right?

17:46 Yeah.

17:47 What are you doing?

17:47 I'm going, I'm going to go to college next year.

17:50 Yeah.

17:50 I'm going to take my yacht on a tour because my business is doing pretty well.

17:53 One day.

17:54 I'll push that on my kids.

17:56 No, I'm kidding.

17:57 Yeah.

17:57 This portion of Talk Python to me is brought to you by Ting.

18:03 Let me tell you about Ting, a new mobile service available in the US that's targeted developers

18:07 and other technically savvy folks.

18:10 First of all, their average customer only pays $23 a month, but they're no discount provider.

18:14 Their service runs over T-Mobile's and Sprint's fast nationwide network.

18:19 If you don't use that much data because you're usually on Wi-Fi, like many of you are, then

18:23 Ting will save you a ton of cash.

18:24 But don't worry.

18:25 You can still use as much data as you like for just $10 per gig.

18:29 One mobile feature I use all the time is tethering.

18:31 And with Ting, you get unlimited tethering at the same data rate with your account.

18:35 $6 a month for a phone line, $10 a gig, $3 a month for text if you usually chat over

18:40 iMessage or WhatsApp.

18:41 Think about it.

18:42 No contracts and super clear and fair billing.

18:46 Visit python.ting.com.

18:47 That's python.ting.com.

18:50 And check out their savings calculator.

18:52 Enter your usage and see exactly what you'd pay.

18:55 Use that link and you'll get a $25 credit to try them as well.

18:58 That's python.ting.com.

19:00 Or just click the link in the show notes.

19:03 All right, Bob, you're up next.

19:05 No, you had to commence on HTML, actually.

19:07 Well, I was pretty happy that you covered it because HTML is so fundamental for a web developer.

19:12 Because when I look at my Django workflow, I mean, part of my time, I'm actually writing

19:17 HTML in the template.

19:18 So it's very important.

19:20 Also, as well as CSS.

19:21 It's always something that needs to be styled, even if you're using a framework.

19:25 So it's kind of, it's very basic knowledge that web developers should have.

19:29 The other thing I'm really astonished by is how far we've come.

19:34 The other day, you needed a progress bar.

19:36 And now you can have this predefined tag, progress, right?

19:39 So no JavaScript, no scripting.

19:41 You can just use a progress tag and give it like a numeric value.

19:45 And you have your, that's pretty cool.

19:47 That is so cool.

19:49 Yeah.

19:49 We really have come a long ways.

19:51 Yeah, but you don't always see JavaScript.

19:53 And I do agree that CSS is actually of those skills.

19:57 If you can learn the basics of CSS, like that is like kind of a web superpower, right?

20:01 That really unlocks a lot of things.

20:03 Another part, though, is JavaScript some of the time, right?

20:06 Yeah.

20:06 No, you cannot escape it.

20:08 And you better learn JavaScript.

20:11 A good part, actually, because most of the web is powered by JavaScript.

20:15 I mean, there's Python, there's the backend always.

20:17 But every page out there uses JavaScript and some of them a lot.

20:22 So the challenge I had, though, I mean, JavaScript is a whole language.

20:26 And I needed to cover it in four days.

20:28 So that was tough.

20:29 So I really tried to become an essentialist and focus on the essential part.

20:35 So the data types and a little bit of ES6, actually, as well, because that's now important to know.

20:42 Yeah, that's basically version six of JavaScript.

20:44 Right.

20:45 Right.

20:45 ECMAScript six.

20:46 Yeah.

20:46 Right.

20:47 So we have arrow functions and destructuring, map and filter.

20:51 So it's likely that you're going to find it.

20:53 So I did cover some ES6.

20:55 And also within this context, I wanted to talk about React, which is one of the major frameworks in JavaScript.

21:02 And again, that was a pretty steep mountain to climb.

21:08 So I decided to actually try to make a game, a hangman game, because games are good when you're handling with variables and classes and functions.

21:16 And you have to keep state as well as use a user interface.

21:20 So I decided to build a game, which was not easy.

21:22 So I decided to build a game, which was not easy.

21:24 But actually, it did give me a way to break a huge topic down into 16 or so segments.

21:31 That's cool.

21:31 What was your thought of React coming from a Python background?

21:36 Like, do you like it?

21:37 What's the general programming model feel like?

21:39 It was a bit confusing at first.

21:41 But then I did start to appreciate it for its design philosophy, especially how it treats mutability.

21:49 So I did end up liking it, yes.

21:52 But it took a little bit to get into.

21:54 There's a lot of moving pieces.

21:55 Yeah.

21:56 As a web developer, it feels a little weird to me because I always tried to aim for, like, separation of concerns, right?

22:03 So you've got your style sheet, you've got your JavaScript, and then you've got your HTML.

22:08 And I've always aimed to have, like, the HTML depend as little as possible on the other two and so on, right?

22:15 Like, try to keep those focused.

22:16 And here, it's like you embed the HTML in the JavaScript little component bits.

22:22 It seems a little funky to me.

22:23 Yeah, JSX, right?

22:25 The new syntax.

22:27 Yeah.

22:27 That's a little weird at start.

22:29 I agree.

22:30 Yeah, I guess if the tooling supports it, right?

22:32 If the tooling treats that little HTML block as HTML, then it's not so bad.

22:36 But it's definitely a mind shift, yeah.

22:38 And there are tools to bootstrap your app.

22:40 For example, I used Create React app, which I think is from Facebook, who invented the whole framework.

22:46 And that did help because you get all your defaults in place.

22:49 And you can just npm start and you have a basic structure in place.

22:55 So that really helped.

22:56 Yeah, that's cool.

22:57 Yeah, a lot of these front end frameworks, JavaScript frameworks have like little bootstrappy scaffolding CLIs for them.

23:04 That's cool.

23:05 So just because I'm a complete noob with JavaScript, right?

23:09 And I'm trying to learn it now.

23:11 So you're, and this is an interesting point from a teaching standpoint.

23:15 You had to squeeze JavaScript into four days, which is just seems unthinkable.

23:20 You had to really whittle that down to people who don't know it, right?

23:25 Teaching it from scratch.

23:27 And so can I learn this myself from zero?

23:32 Yes, you can.

23:32 Okay.

23:33 Now, so this is actually more for me than anyone else.

23:35 I mean, it assumes some basic programming knowledge.

23:40 I mean, you do need to know what a variable is, but it starts very basic with the data types and basic construct looping and all that.

23:49 And, you know, if you already know Python or another language, I mean, a lot of stuff sounds familiar, right?

23:53 I mean, a list or array in JavaScript, you can slice as well.

23:58 Or, well, you can take an index.

24:00 You cannot actually slice it.

24:02 Or you can slice it, but it's dot slice.

24:04 So it's all very similar, the concepts, but the syntax is sometimes different.

24:09 Okay, cool.

24:10 Cool, cool.

24:10 All right.

24:10 Julian, you focused a lot on Flask.

24:13 So you cover one of the plugins for Flask called Flask Login, right?

24:17 Yeah.

24:18 So this one was more like a bucket list item for me.

24:21 For ages, I've wanted to deal with how to log in to a website using Flask.

24:27 And I got to tell you, Mike, this one, I wanted to rip my hair out by the end of it.

24:32 I think it took me a solid month to wrap my head around it.

24:35 For anyone who's not familiar with Flask Login, the actual Flask Login part is the easy part.

24:42 Everything you need to learn before that is SQLAlchemy to build yourself a database, to build yourself a model for your users to be able to log in.

24:52 And I'd never dealt with any of that before.

24:55 So this was one of the major learning points for me in this whole challenge, this 100 days.

25:00 But it was the most satisfying thing to figure out.

25:03 When you look at my page, as you said, Mike, it's HTML from back in 1996.

25:09 I think my page looked even worse than that.

25:12 But to see a logged out and a logged in sort of view, I think I had a few beers that night to celebrate.

25:20 Nice.

25:22 Yeah, it was one of the most satisfying things because it's actually really simple once you get your head around it.

25:29 There is a whole lot of SQLAlchemy you have to learn or I have to learn.

25:34 And I teach this before you get into the Flask Login.

25:37 And that was the hardest part for me, as I've just said.

25:40 But if you can get through that and if you know that stuff, then the actual Flask Login is pretty easy.

25:46 I think one of the greatest parts of it is, you know, as with Flask, there's a lot of stuff with decorators.

25:53 And there's this amazing little decorator you can throw on any of your functions for the, you know, the web pages that you're going to be running on your site called, I think it's just Login.

26:04 Or is it?

26:05 No, no, what is it?

26:06 It's Login Required.

26:07 Login underscore required.

26:08 And you throw that on any of your pages, any of your routes.

26:12 And if someone tries to browse that page, it'll check to see if they're logged in or not.

26:17 And it was as simple as that.

26:19 You sort of had to do nothing else to your site to be able to do that, to get the Login page to work.

26:26 That was probably the most satisfying part of using Flask Login.

26:29 So that was a really good one.

26:31 And if you haven't given it a try, just give yourself a few hours and give it a chop because it actually is quite simple to use.

26:38 And once you implement a Logout page to create users so that people can actually register an account,

26:45 tie all that in with an SQLAlchemy database back end, and this thing just is beautiful after that.

26:51 That's cool.

26:52 Yeah, it sounds like a really nice way to do it.

26:53 And these plugins for Flask are definitely cool.

26:55 It also, if you're using Flask anyway, there's a high probability if you're using SQLAlchemy also, right?

27:02 Like Flask is a micro framework and doesn't come with some ORM.

27:06 So as long as you're using a relational database, the chances are very high you're using SQLAlchemy.

27:10 I mean, you could be using something else like there's PeeWee ORM, which is nice.

27:14 You might be using something like Mongo Engine for MongoDB.

27:17 But, you know, most likely SQLAlchemy.

27:19 So you're already kind of in that space, right?

27:22 So here's just the user aspect being handled for you.

27:25 Well, the tough part as well is if you're a brand new person to Flask, that getting from that single page Flask app to running a fully fledged Flask app with, you know, your directory structure and views and also having a database.

27:40 There's a massive leap there that you have to make.

27:43 So get the SQLAlchemy down.

27:45 That's the first part.

27:46 Then work on your plugins.

27:48 Yeah, absolutely.

27:49 I feel like I'm not sure what the right way to put it, but I feel like Flask sells itself as being so super simple, right?

27:55 Like I create the one file.

27:56 I create app.py.

27:57 I call the Flask thing to create the app.

28:00 I use that to decorate a function.

28:02 Hello, world.

28:02 App.run.

28:03 We're good, right?

28:04 But in reality, there's all these other things to it, right?

28:07 There's like the database access and the structure and the factoring and the testing.

28:10 And there's more to it than initially meets the eye when you create these things.

28:14 It's almost like a false sense of security.

28:16 Yes.

28:17 Yeah, that's why I kind of said I wasn't sure how to put it because it doesn't – I don't necessarily put that forward as a positive, right?

28:22 Like Flask sells itself as like, oh, it's just this one file.

28:24 But like if you really create an app that's just one file, like a whole website, like you're probably doing it wrong.

28:30 You know what I mean?

28:30 Like it's so important.

28:32 It's kind of like encouraging you to not do the best thing.

28:34 So anyway, it's still – it's a great framework.

28:36 I like it.

28:36 All right.

28:37 I guess that puts me next here.

28:39 So the next thing I want to talk about is also Flask.

28:42 And this one is called Court.

28:45 So this puts together a couple of ideas that I find really interesting in Python.

28:49 You know, a lot of times you hear people tell you that like asynchronous programming in Python is super complicated.

28:57 And it's basically broken.

28:58 And like you can't really use it anyway because of the GIL and stuff like this.

29:02 And I did a lot of thinking about this and a lot of research on this.

29:05 And actually, I think as of Python 3.5 and beyond, like that's not really true.

29:10 It's not really – I don't think it was totally true before and it's definitely not true these days.

29:14 I think asynchronous programming in Python is really interesting.

29:17 So I'll talk about that in a second.

29:19 But also things like Flask and Django and Pyramid, none of those support async programming, which is odd.

29:26 I mean, it strikes me as odd.

29:27 Does it strike you guys as odd?

29:28 Yes, a little bit.

29:29 Yeah, I'd expect so these days, but it is weird.

29:32 Exactly, right?

29:33 Like what web apps basically do is they talk to other systems and like coordinate it and then they wait while that happens, right?

29:40 Like you make a request.

29:42 It talks to the database.

29:43 It waits.

29:43 Maybe it has another question for the database after it figures out what user it is.

29:47 It's going to ask like, well, what's in this category?

29:49 They post it over to me and it waits for that.

29:51 And maybe it's going to call an API and wait for that.

29:53 Maybe it's a cache and it'll call Redis and wait for that.

29:55 And it's going to put those answers together in a template and give it back to you, right?

29:59 Like it's all about coordinating waiting basically is the way I see the web.

30:02 And yet that's the perfect scenario for asynchronous programming.

30:07 Like let you do other stuff while you're waiting on the database because you're actually not doing any work.

30:11 You're just waiting.

30:12 But because of the history of the way these frameworks are built up, they're all based on WSGI.

30:16 WSGI is like basically single thread requests.

30:19 There's not a great way to do it.

30:20 So if you do want to do that, you have to pick one of these many plethora of these brand new frameworks.

30:26 Or you could pick this thing called Cort, which is cool.

30:29 And I've covered this on Talk Python before.

30:31 But Cort is basically a API and plugin level compatible thing with Flask.

30:39 But it supports asynchronous methods and async and await and all that kind of stuff.

30:44 So that's pretty cool.

30:44 So you just basically replace the word Flask with Cort.

30:48 If it's a lowercase Flask, it's a lowercase Cort.

30:50 If it's an uppercase F on the Flask, it's uppercase Q on the Cort.

30:54 And like that's pretty much it.

30:55 And things like Flask login and all that stuff still work with it.

30:59 And yet it allows you to write async def home or async def login or async, you know, whatever view you want, you can do async stuff.

31:08 And within there, you can await your database call.

31:11 You can await your Redis key lookup and things like that.

31:14 That's nice.

31:15 Oh, that is cool.

31:16 Yeah.

31:16 So it's really nice.

31:18 It's interesting if Flask, sorry, if Cort is going to be its own thing in the long term.

31:22 I know there was some conversation with David Lord and the maintainer of Cort about maybe like somehow working together if they're so similar.

31:31 Like, could we just make Flask async?

31:33 And Flask does have async on its roadmap.

31:36 I know there's a conversation about Django's async roadmap and things like that.

31:40 So, you know, these other main frameworks are working towards that, but they're already existing.

31:44 I don't know.

31:45 It's a challenge, but there's a bunch of really interesting things there.

31:48 And the other thing I want to throw out while we're on this topic that I thought was just one of my favorite things is there's all these different ways to do asynchronous programming in Python.

31:56 Like we've got threads, we've got processes, we've got asyncio, which uses the async and await keywords.

32:02 But for some reason, threads, you can't use async.

32:05 You can't await a thread, which is weird because you should be able to.

32:08 Things like that.

32:09 But there's this thing called unsync.

32:11 And unsync lets you put a decorator on all of your asynchronous methods.

32:18 And it will figure out which type of asynchronous programming or execution is appropriate for it.

32:24 So sometimes it'll use threads.

32:26 Sometimes it'll use asyncio.

32:27 Sometimes it'll actually create subprocesses.

32:29 But your program model is all the same.

32:32 It's just async and await straight across the board.

32:34 It's a beautiful library.

32:36 I just love that thing.

32:37 And I don't think we talk about it in the course here on this stuff, but it's definitely worth checking out if you're doing much with async and await.

32:44 It's definitely cool.

32:45 So anyway, if you want to play with this conversion from Flask to core for async bits, that's days 21 to 24 in the GitHub repo.

32:52 Great.

32:52 Yeah, that's a fun one.

32:53 Speaking of Django and its async roadmap, Bob?

32:57 Speaking of Django, I wanted to ask you, is the async on the roadmap?

33:01 Anyway, if it's not, it's still my favorite.

33:06 So a big chunk.

33:08 Yeah, the Django guys are talking about it.

33:09 They're playing it.

33:10 It's just not there yet.

33:11 I'm sure they are.

33:12 Yeah, I'm a big fan.

33:15 And so a big chunk of the research and the coverage I had in the course was Django and Django logging registration and Django REST.

33:26 So also Django is a very big topic and people find themselves with a steep learning curve.

33:33 So the best way to go is to build a very simple CRUD app.

33:38 So create, read, update, delete.

33:41 And I built a quotes app with one model.

33:45 Very simple, but a great opportunity to look into Django's ORM.

33:49 So if you're not familiar with these frameworks, one of the things they do is get rid of you writing raw SQL.

33:57 So you can use the object relational mapper or ORM and it makes it very easy to talk to a database.

34:04 And Django's ORM I really like.

34:07 I mean, it's very intuitive and the syntax makes a lot of sense.

34:10 Yeah, and Django is different in the sense that like Julian and I were talking about SQLAlchemy, which we both like.

34:16 But SQLAlchemy is its own separate thing and you choose to bring it into Flask or Pyramid or something like that.

34:21 But with Django, it comes with its own like more integrated data access layer, right?

34:26 Right. That's a great addition.

34:27 Yeah, because yeah, Flask, you have to set it up separately and usually you go with SQLAlchemy.

34:32 But Django has all the stuff in the box.

34:35 It's a complete solution.

34:36 Also the templating, I think for Flask, you would use Jinja and Django has its own templating engine.

34:44 So Django is great if you want to have a complete solution out of the box, but then it is opinionated.

34:50 So some people like it, some people don't.

34:52 And I do like the decisions they made.

34:55 What do you like, Django or Flask?

34:56 What do you think?

34:58 It's a never-ending battle between you and me.

35:01 You're Django, man.

35:03 Fine.

35:04 Yeah.

35:05 So another thing I covered was, I mean, always, usually if you make a website, you need some sort of registration and login.

35:14 So I covered the Django registration plugin, which recently was upgraded to 3.0.

35:20 Great plugin.

35:21 If you need to capture emails and do two-way authentication.

35:25 So you need to send an email, confirmation email for a user to confirm and register.

35:31 The only thing confusing was that the templates were missing.

35:35 So I ended up providing them in a zip file.

35:37 Even so, I would really recommend looking into that plugin, which is called Django registration.

35:42 And lastly, in this context, I also covered Django REST.

35:46 As we mentioned before, same author as API star.

35:49 And yeah, it's another great framework that makes it easy, relatively easy to build APIs, but do it on top of your Django models.

35:58 So I use the same quote app.

36:00 Right.

36:00 If you've already got your Django models made for your web app, like if you want to expose that as a RESTful endpoint, like this is a supernatural choice because you only have to put the API, like a thin API layer on top of what you already got.

36:12 Right.

36:12 Yeah, you basically make a serialization module and that's almost all you have to do.

36:18 So it makes it really easy.

36:20 And it has also support for permissions.

36:23 So I think that's done via some middleware.

36:27 And yeah, I also plugged in a swagger for documentation.

36:31 And yeah, it was all pretty easy, relatively a few lines of code.

36:36 So I really liked Django REST framework and I can highly recommend it.

36:40 That's cool.

36:40 Do you use Django REST framework in your code challenge platform?

36:43 Yeah, good question.

36:44 I actually not.

36:45 Just use Django, but not Django REST, right?

36:47 Yeah.

36:48 Django made that pretty easy to do.

36:50 We just manually made some API endpoints.

36:53 Yeah.

36:54 Yeah, I ended up doing that a lot as well.

36:55 We were thinking though, at some point we need a mobile app or something and we need to make an API for the whole thing.

37:02 Then we definitely want to use it.

37:04 Yeah, for sure.

37:05 I've been down that road.

37:07 Yeah, another module I want to highlight was SendGrid for emails.

37:12 Because with the registration plugin, you have to send a verification link.

37:18 And SendGrid makes it very easy with their API to send emails.

37:23 So I use that as well in this context.

37:25 Yeah, the days are a long call and you should set up your own SMTP server and talk to it locally.

37:30 Using something like SendGrid makes a lot of sense.

37:32 Yeah, and I think I also at some point tried to use Gmail, but then it doesn't really like being used as an API or so.

37:40 So it's security concerns.

37:42 So it's not, that was not a success.

37:44 Lessons you learn.

37:46 Why is my email not getting delivered?

37:48 This portion of Talk Python to me is brought to you by Linode.

37:53 Are you looking for hosting that's fast, simple, and incredibly affordable?

37:57 Well, look past that bookstore and check out Linode at talkpython.fm/Linode.

38:02 That's L-I-N-O-D-E.

38:04 Plans start at just $5 a month for a dedicated server with a gig of RAM.

38:08 They have 10 data centers across the globe.

38:10 So no matter where you are or where your users are, there's a data center for you.

38:14 Whether you want to run a Python web app, host a private Git server, or just a file server,

38:19 you'll get native SSDs on all the machines, a newly upgraded 200 gigabit network,

38:24 24-7 friendly support, even on holidays, and a seven-day money-back guarantee.

38:28 Need a little help with your infrastructure?

38:30 They even offer professional services to help you with architecture, migrations, and more.

38:35 Do you want a dedicated server for free for the next four months?

38:38 Just visit talkpython.fm/Linode.

38:41 Julian, what do you got for the next one?

38:44 So the next one is actually kind of simple, but again, it was very satisfying, a lot of fun to do.

38:50 So I did some Heroku deployment on, what was it, day 65 to 68, something like that.

38:57 And it was really satisfying.

39:00 So I know with Netlify, I was able to deploy a static site and have it all hosted.

39:06 But this time I wanted to get my Flask app.

39:08 And one of the best parts was the Flask app that I was creating throughout all of the course.

39:14 It's all running local.

39:15 You know, it's all local on your desktop.

39:17 So this was the chance to get it out on the web, to get it running in a dyno on Heroku and just deployed out there so I could spam it to all my friends and family and say, look what I made.

39:28 And they make it really simple.

39:30 And this is why I think we use Heroku as well for quite a few things on the side, but they just make it too easy.

39:37 And the best part is with your Flask app, they fully support Flask.

39:42 So you can just deploy it.

39:44 You link the repo that you've created locally to Heroku.

39:48 And again, when you push the code up to Heroku, it processes and it actually deploys your site onto your dyno and it's live.

39:58 So I think the only thing you really need to throw into your code is a little proc file and a couple of little tags here and there.

40:07 And that's it.

40:08 Heroku takes care of the rest.

40:09 So it's actually really simple.

40:11 That was part of what I covered in that section of the course.

40:15 But I also wanted to highlight some of the cool features Heroku has.

40:19 And again, I'm going to say, I know this sounds like a massive plug for Heroku, but it's not.

40:22 I just really like what they do.

40:24 They have a lot of plugins that you can use.

40:27 I think they call them plugins.

40:29 Yeah, whatever.

40:30 We're going to call them plugins.

40:31 We're going to call them plugins today.

40:32 So there are two that I wanted to cover.

40:35 Bob just mentioned one, SendGrid, because we use SendGrid a lot.

40:38 So again, you can hear that a lot of the stuff we're discussing here, we use actively.

40:43 So that's why we wanted to cover it in the course.

40:45 But this SendGrid plugin, it links, the add-on, it links with your SendGrid account.

40:52 And it's the most minimal amount of code to throw into your code base to then shoot off an email automatically.

40:59 And it just works really well.

41:02 So I really enjoyed that, teaching that.

41:04 In fact, I think the hardest part was making that section take a day, because it was so easy to teach.

41:12 It was, you know, I was struggling for things to say.

41:14 I probably should have just sang a song or something.

41:17 But then the other one I wanted to cover off was Heroku Scheduler, however you want to pronounce that word, scheduler.

41:23 But it's just essentially cron, and it makes your life so much easier.

41:28 You don't need to go into any backends and worry about it.

41:31 It has a nice web interface if you're that way inclined, like me.

41:35 And it's just super helpful.

41:38 You can automate so many tasks.

41:40 You can little parts of your Flask app, whatever you want, with this little scheduler.

41:46 Literally put in the code that you want it to run every time.

41:49 And it's just, it's really easy.

41:51 Really pleasant to use.

41:53 Really pleasant experience.

41:54 It's not something you get to say very often.

41:55 Yeah, that's a great way to describe deployment, right?

41:58 Like, normally deployment is something that people got to learn a lot about.

42:01 It's really tricky, and stuff goes down.

42:03 Like, where are the Nginx logs?

42:06 It says it doesn't work, but I don't know why.

42:08 I can't figure out where the logs are.

42:10 You know, like, so this is really nice.

42:12 I know there's a lot of people, like you guys, who love platform-as-a-service stuff, like Heroku.

42:17 But there's also a good case to be made if you want a bunch of VMs, depending on, like, how you want to configure things and whatnot, like on the node or something.

42:24 So, yeah, definitely, if you're inclined towards the platform-as-a-service side, that sounds like a good option for sure.

42:30 Yeah, definitely.

42:31 All right, so the next one I want to talk about kind of has to do with, like, deployment and evolving your app over time as well.

42:36 And that's database migrations.

42:39 So, if you're using SQLAlchemy, Mike Bayer created this thing, who also created SQLAlchemy, created this thing called Alembic.

42:45 And if you're using Django ORM, there's migrations built into that as well.

42:51 And the idea is that regardless of which one you're using, but I'll talk about SQLAlchemy just to have something concrete.

42:57 If your SQLAlchemy class structure does not match what your database structure looks like, your app is coming to an abrupt screeching halt, right?

43:07 Oh, yeah.

43:08 You're going to get a, you know that, right?

43:09 You're going to get a 500 error.

43:10 It's going to say operational error database schema, like this column doesn't exist or something terrible like that.

43:16 And you'll be like, whoa, that sounds kind of bad.

43:19 But, like, if you make a change to your code, like add a column or something, and then you deploy it, boom, your app is taken offline, right?

43:26 Like, it will no longer talk to the database.

43:27 It's a problem.

43:28 So, how do you manage that, right?

43:29 Like, some people probably, like, evolve the database manually.

43:33 That sounds a little scary to me.

43:36 Just because it's, you've got to write the SQL transformations to do it right or, like, open up the tool and edit it.

43:42 So, what's great with Alembic is you can just point it at your SQLAlchemy models, point it at your database.

43:47 There's a little bit of configuration to set it up.

43:49 But then you can just run a command, auto-generate the migration.

43:54 And it'll look at your classes and it'll look at the database and go, well, this column was dropped.

43:57 This one was added and this index was updated in this way.

44:00 And then it just lets you run a command line operation that will automatically transform the database like that.

44:07 So, one developer makes a change.

44:08 The other developer checks it out.

44:09 You know, obviously, that change needs to accompany a migration.

44:13 So, then they can just run the migrations as they get the new version of the app.

44:16 You push it to Q&A or staging.

44:18 You run the migration.

44:20 And then as part of your deployment, you can just have it always run a migration.

44:24 And, like, if there's no operations, it just goes, you know, if it's up to date, it just goes, eh, nothing happens.

44:29 So, we'll just keep going.

44:31 So, it's a really nice way to make sure that your database constantly stays in sync with your ORM models.

44:37 Oh, that is really cool.

44:38 Yeah.

44:39 And when I first looked at it, I'm like, whoa, this looks complicated.

44:42 Why is this so hard to set up?

44:43 Maybe it is.

44:44 I don't know.

44:44 There's a few little hitches that, like, cause some challenges about, like, how do you import the models correctly from the context of executing within Alembic and stuff like that.

44:53 But once you get it all figured out, it's not too bad.

44:55 We covered that in day 61 to 64.

44:57 So, you can go check out the little sample code there.

45:00 Another alternative is to just not use a relational database.

45:03 Like, you know, all my stuff, like, in production runs on MongoDB.

45:06 And MongoDB doesn't have this problem.

45:09 But it also has basically an ORM, something called an ODM for them.

45:12 Mongo Engine is what I use.

45:14 And it's basically like SQLAlchemy.

45:17 It's more like Django ORM, actually, but same idea.

45:19 But MongoDB doesn't have this problem in general.

45:22 So, you don't have migrations really there.

45:25 You can sidestep it that way.

45:26 But a lot of people want to use a relational database.

45:29 And if you do, migrations.

45:30 It's a great way to solve the problem.

45:31 Ah, that's really cool.

45:33 And I can see it's, so I'm just on the documentation.

45:35 And it's actually alembic.sqlalchemy.org.

45:39 So, yeah, very cool.

45:41 Yeah, yeah, same organization, same people behind it.

45:43 Bob, do you guys use migrations, the Django migrations for what you're doing?

45:46 Yeah, very simple.

45:47 Make migrations.

45:49 That makes a file you commit to version control.

45:52 And then just migrate.

45:53 And then it syncs it to the database.

45:55 Works great.

45:56 Yeah, sounds real similar to the auto-generate feature there.

45:58 It's cool.

45:58 All right, Bob, what's your last one?

46:00 Slackbots.

46:02 That was one of the most fun chapters I worked on.

46:07 And, well, we all...

46:09 Slack is used for all sorts of things, right?

46:11 Like, people chat with it.

46:11 But it's also got so many integrations, right?

46:14 Like, for example, if, like, I have an error on my website, I have a Slack channel that Rollbar will detect the error on my website

46:22 and then post a message to me on Slack that there was an error on the website, right?

46:26 And that's like a Slack bot, sort of.

46:28 Sort of, I guess.

46:29 But, yeah, there's all sorts of uses for it.

46:31 Yeah, when people do a pull request or a code challenge repo, we get a notification in our pull request channel.

46:38 But also, if you think about, like, the general Slack bot, it's super useful.

46:42 Like, you can set reminders and stuff.

46:44 So, yeah, bots overall are becoming more popular.

46:48 So, it's a nice skill to have, I think.

46:50 And so, yeah, for this chapter, I looked into Slack API.

46:56 And we made a random book slash command.

47:00 So, if you type slash book in our Slack, it reaches out to some books API we have for another app we run.

47:08 And it posts back some random title.

47:09 You can also do slash book and then user.

47:12 And you get the last book for the user.

47:14 So, that's fun.

47:15 That's cool.

47:16 And what's nice about these apps is that there's a lot of moving pieces.

47:20 So, it's not only the Slack API, but you have to call another API to get your data.

47:25 So, in this case, that was Google Books API, which I think has been around forever.

47:29 And we had to make a little Flask app for the slash command to actually grab data.

47:37 So, it was and retrieving data from an API and making an API.

47:40 And then, before rolling it out, you want to test your local server on the internet.

47:46 And for that, I used ngrok, right, which is a pretty important tool if you want to, how would I say that?

47:55 Link your local host to your internet address or make your local host available on the internet, so to say.

48:01 So, you get this kind of temporary IP.

48:03 And anybody connecting to that IP is actually talking to your local web server, which is cool, useful.

48:10 I'm so glad you covered ngrok here.

48:12 You threw this in here because ngrok is incredible.

48:15 So, like, if I type ngrok and I give it a port, it'll say I could map, like, port 5000 if I was doing Flask.

48:24 Locally, over to, like, 88532ff5.ingrok.io.

48:30 And it actually has an HTTP and HTTPS version.

48:33 So, at first, I thought, oh, this is kind of interesting.

48:36 But I've been using this for some incredible stuff.

48:39 So, for example, when I was developing my mobile apps, I wanted my phone where I had the debugger attached to my phone to be able to talk to the web services that I was building locally with the debugger and PyCharm attached to the web service.

48:54 Right?

48:55 And, of course, I could drop my firewall and, like, set this up and, like, all.

48:58 But we just run an ngrok command.

49:01 You don't need to change firewall settings on either end.

49:04 It just automatically goes through the internet, through HTTPS, and then right back in there.

49:08 And you can step through one, step through the other.

49:11 Another one was I was doing some integration with Gumroad for the purchasing of the PyCharm book that Matt Harrison and I wrote.

49:18 And we had to do some – there's one option you can buy where you also get a course.

49:22 And so, it had to, like, create an account and, like, put you in the course.

49:24 And, like, it wasn't working.

49:27 So, I put the URL it was supposed to work and it wasn't working.

49:29 Like, why is this not working?

49:30 And, like, why don't I just put the ngrok URL in there?

49:32 And I was literally stepping through in the debugger, Gumroad's callback into, like, my local machine, into PyCharm, into the APIs I was creating.

49:41 It is so cool, this ngrok thing.

49:43 It's definitely underestimated.

49:44 That's really cool.

49:45 If you cannot debug something on local host, you're lost, right?

49:48 Right.

49:49 I mean, here you want to have Slack, in your example, you want to have Slack send a message over and it goes to your HTTP endpoint to do something and then it gets a response.

49:57 Like, you can't debug Slack, right?

49:59 That's their infrastructure out on the internet.

50:01 But you can actually, like, deeply run and iterate on, like, your local version using ngrok.

50:07 It's awesome.

50:08 Yeah.

50:08 Yeah, okay.

50:09 I'm excited about that.

50:10 I got to stop.

50:11 But, yeah, definitely you found it valuable as well, huh?

50:14 No, that is cool.

50:15 So, the whole ngrok thing is amazing.

50:17 I didn't even know you used that, Bob, in that part of the course.

50:20 Did you create any other Slack bots other than just the books one?

50:24 There's one we actually use quite a bit.

50:26 which is called Karma Bot on our Slack.

50:31 And if you want to give people credit for contributing to the community, helping each other out, you just use add handle plus plus.

50:39 And Karma Bot keeps a local database of users' karmas.

50:46 So, the user then gets extra points.

50:49 And it's funny how people sometimes react to that gamification.

50:53 Definitely boost community participation.

50:58 And, yeah, it's all run by a Slack bot.

51:01 It's kind of funny.

51:02 It's a bot, but people kind of treat it as a human at some point, right?

51:06 That's really one of the most satisfying projects.

51:11 It's not in the course, but it's on GitHub.

51:13 We will link to it.

51:16 That's another example of a bit more elaborated Slack API project.

51:20 For sure.

51:21 Julian, you want to wrap up your section with Chuck Norris?

51:24 Oh, yeah, I do.

51:25 So, while we're having a bit of fun, this was the most fun I had in the course from an actual fun standpoint.

51:33 So, what I wanted to do is, I guess I'll give you the quick background.

51:36 It was Flask, but what I wanted to do was give the users a sort of real-life use case.

51:42 So, when you make a Flask app, especially when you're learning Flask from the start, one of the easiest things to do is to try and talk to an external API.

51:51 So, not make a Flask API, but just go out to an API, pull some data, and then present it on your Flask app webpage.

51:59 So, that involves, you know, setting some gets, getting some posts potentially, and then presenting that data.

52:06 So, doing something with it to present it on your page.

52:08 And it's all little simple bits, but combining it all together is...

52:13 I remember when I first learnt this was a bit complex.

52:16 So, I wanted to demonstrate that in a few days.

52:19 And probably the fun part here was choosing some interesting APIs to play with.

52:25 And the first one I chose was the Pokemon API.

52:29 Actually, no.

52:29 The first one I chose was Chuck Norris.

52:31 So, there were two, Pokemon and Chuck Norris.

52:33 And the Pokemon one was really nice because what I was getting people to do was enter in a color on the webpage that you create.

52:42 And that color then shoots off to the Pokemon API and returns...

52:47 You get returned a list of all Pokemon with that color.

52:51 And then, you know, the course shows you how to list that data on your page or print it onto your page.

52:57 So, really simple stuff, but really actionable.

53:01 And you get that instant feedback of, hey, look what I just made.

53:04 This is cool.

53:05 And because you get to see the Pokemon API, you get to see all the cool little things that you can pull.

53:11 So, I've seen people on Twitter who then expanded on this, like spread into another day or two and got all sorts of other information from the API.

53:19 And it was just really cool to see.

53:22 But what was actually quite hilarious was the Chuck Norris API.

53:25 So, I couldn't believe it existed first and foremost, which just killed me for a day.

53:31 But the API just returns a Chuck Norris joke.

53:35 And the reason this is so funny is because obviously the jokes are hilarious and lame and terrible, whatever.

53:41 But I didn't realize they were some could kind of be inappropriate.

53:47 And I didn't realize until after I'd recorded everything and put all this time into the course.

53:55 And then I got to the end.

53:56 I'm like, oh, that joke wasn't fantastic.

53:58 So, I think there's a disclaimer in the course now saying, look, just please ignore any jokes.

54:02 Just this is more for the API, not so much for the joke.

54:05 Yeah, it's funny though.

54:06 This was a great chapter to do.

54:08 It's really actionable and a lot of fun.

54:09 Yeah, and consuming APIs, especially from Python where we have requests and other things like that, AIoHCP client, for example.

54:16 It's so accessible.

54:18 I think before people try it, if they haven't, it sounds like, oh, this integration might be hard.

54:23 Like, usually it's not.

54:25 Yeah, it's actually quite simple.

54:27 And probably the best part is when you're dealing with that sort of thing generally, or a lot of use cases will have you use forms.

54:34 And doing the very simplistic Flask forms that are built in are nice.

54:39 And then it's a nice gateway into the WT forms that Flask has as well.

54:45 Yeah, it's good.

54:46 A lot of good stuff in that one.

54:47 Yeah, great.

54:47 I want to wrap it up with some JavaScript stuff, actually.

54:52 One of the things that I'm not really a super fan of JavaScript, although I use plenty of it here and there.

54:59 You know, a lot of people, when they create web apps, they think it has to be like a JavaScript front-end thing, like React or Angular or Vue or something like that.

55:07 And then, like, maybe there's some API endpoints.

55:09 And I always find apps like that are, I don't know.

55:14 They're okay, but they always seem to, like, break down or have these little glitches or just, like, weirdnesses about them.

55:19 So I think you can still build amazing apps that are mostly server-side with a little bit of JavaScript here and there as you need it.

55:27 But if, for some reason, you do want to build, like, a progressive web app that has an offline capability or something that's a single-page app for whatever reason that doesn't navigate, you know, one of the options that I looked into was Vue.js.

55:39 As opposed to, say, Angular, which is, you know, it's got a lot of structure.

55:43 It requires TypeScript and things like that.

55:46 Bob, you talked about React.

55:47 And actually, React is really cool.

55:49 There's some great examples.

55:50 There's this one of building a whole bunch of different apps, and one of them is this, like, recreation of the Mac calculator.

55:57 And it looks really, really good.

55:58 I'll link to that as well.

55:59 So React has got some cool examples and options.

56:02 But I just found Vue.js to be so clean and simple.

56:06 You just create a little Vue.js app in JavaScript.

56:08 You give it values like name, colon, right, nothing or string or whatever.

56:15 And it does two-way data binding.

56:17 It's got a lot of plug-ins for editing it.

56:19 So if you're building these front-end apps, I definitely recommend people check out Vue.js.

56:24 It's just, it's got, like, a real minimal, easy-to-get-started type of front-end framework there.

56:29 So another thing that I thought was interesting was Axios.

56:33 And, Bob, you and I talked about Axios as well, right?

56:36 Like, Vue.js doesn't have a native way to talk to web services.

56:39 But Axios, this is a JavaScript plugin library.

56:43 I will link to that as well.

56:44 It's a super simple way to talk to APIs from your JavaScript.

56:50 And it's just, I don't know, I love it.

56:51 I'm like, wow, this actually makes this so incredibly easy.

56:54 It's a super useful library.

56:56 I used it as well in the React chapter to retrieve data from a Python tips API, another API we set up just for the course, another API.

57:06 And, yeah, it made it so easy to retrieve data.

57:10 It's really, if you're working with JavaScript and APIs, you should check out Axios.

57:15 And then I want to throw in two other quick things.

57:17 There's something called the Quasar framework, which builds on top of Vue.js.

57:22 And it has a whole, just a ton of these, like, widgets and controls that you can just, in Vue.js, just include.

57:31 And you get all sorts of great, like, higher-level UI elements that are just pre-built and plugged right into Vue, which is pretty cool.

57:39 And then the other thing is something called Vue.py, Vue.py.

57:45 And so this is a Python layer, so you can write Python code in the front end of your browser that actually is Vue.js bindings.

57:56 Wow, cool.

57:57 That's really cool.

57:58 Yeah, it's really cool.

57:59 So I think it uses Brython.

58:01 Let me look real quick, but I'm pretty sure.

58:03 Yeah, so you can define, like, a Vue component, for example, by just deriving from the Vue component.

58:09 So, like, from Vue, import Vue component, class, hello Vue.py, parenthesis, Vue component.

58:15 And it's really quite interesting there.

58:17 So I'm not sure that it's a good idea, but it's a very interesting idea.

58:22 Maybe it's a good idea.

58:23 It depends what you're building, right?

58:24 Like, if you're building something that's really sensitive to download, like, I think the Brython element or something is, like, you know, it's not entirely small.

58:34 The JavaScript, you've got to download to get that to work.

58:36 But, yeah, it's Brython.

58:37 So still, like, if it's an offline app or, you know, an intranet app or it's going to be bundled up into something like Electron.js, well, then you don't care about the file size, really.

58:47 So Vue.py is pretty interesting.

58:48 That was Dias 93 to 96, and people can check that out.

58:52 There's an example of consuming a movie service API using Axios and Vue.js.

58:58 Well, you guys, that's pretty much it from our course and the topics we're going to cover.

59:02 Mostly that's it for time because we've covered a lot, right?

59:04 Oh, yeah.

59:05 A lot of technology there.

59:06 That's, like, six months worth of content.

59:08 Yeah, I would say.

59:09 And, you know, this is only 12 topics.

59:11 So we covered maybe 13 or 14.

59:12 A few got kind of doubled up.

59:14 In the course, we actually covered 28 different technology topics in these different segments, which is pretty insane.

59:21 So let me just ask you about this.

59:23 What is, like, after going through all these topics and researching them and studying them, what's your kind of takeaway from this whole exploring the web broadly experience?

59:33 Okay, so for me, I would say it's just that there's so much out there.

59:39 If you listen to all the noise that you hear on Twitter, if you listen to all the stuff that you find or you read everything that you find and you don't actually just choose something to focus on, you're never going to learn anything.

59:52 So my takeaway is, okay, yes, there's all sorts of JavaScript frameworks out there.

59:57 Yes, there's all sorts of web frameworks for Python.

01:00:00 Choose one.

01:00:01 Learn what you need to learn to get your job done and then be happy with that because there's always going to be something else that could potentially do it better.

01:00:10 And then once you've got your thing going, then potentially look at something else that might iterate over that.

01:00:16 But, yeah, I just couldn't believe, as I was doing a lot of the research, I couldn't believe how much is out there.

01:00:22 And as you were saying, Mike, how quickly new things pop up because by the time we finished making this course, there was stuff that was around that wasn't there when we started.

01:00:31 And vice versa.

01:00:32 Yeah, stuff that wasn't there when we finished.

01:00:36 Exactly.

01:00:37 There was, what's that library that Kenneth Reitz makes the, not request the other one that he just came up with?

01:00:44 Responder?

01:00:45 Responder.

01:00:45 Like that came out while we were making this course, I'm pretty sure.

01:00:48 So that sort of thing is just going to keep happening.

01:00:51 So this is why I'm flask and Bob's Django.

01:00:54 Bob, what are your thoughts on this?

01:00:57 My takeaway is similar.

01:00:58 There's so much going on that it's easy to get scared and it's daunting.

01:01:03 But I think it comes down to grasping the fundamentals.

01:01:07 So for me, that really is some HTML, CSS and JavaScript.

01:01:13 You absolutely want to know at least the basics of those.

01:01:16 And for Python, yeah, look into a framework.

01:01:19 There are people with more preference for flask, do it yourself or Django, the whole suite in one.

01:01:26 I'm more the latter.

01:01:28 And then I guess go deep in the framework of your choice.

01:01:32 And another, yeah, fundamental.

01:01:34 You always want to know some database skills, even some raw SQL I would recommend.

01:01:40 And yeah, so the fundamentals and then choose the tools of your preference and go deep.

01:01:46 Yeah, that's good advice.

01:01:46 And definitely, Julian, you're right that you can just spend your time constantly chasing

01:01:51 like the next new thing.

01:01:53 And they come and go so fast that like you will never actually get to somewhere to be

01:01:57 like doing something concrete and building it on if you just keep doing that.

01:02:01 Just pick one of these things, start learning, right?

01:02:05 Like you can always transition later for the next project if you decided you like something

01:02:08 better in the end.

01:02:09 But you just got to like put a stake in the ground and start somewhere.

01:02:12 The other one I'd like to point out is you don't have to learn JavaScript to build decent

01:02:18 web applications, right?

01:02:19 Or if you do, it's an extremely small amount.

01:02:21 Like if you listen to people talk on the web, it's like, oh, you got to know like Angular,

01:02:26 you got to know this, you got to know that.

01:02:27 And it's like you can, but you absolutely can build awesome stuff with Django, Flask, Pyramid,

01:02:32 whatever, just using server side stuff and maybe like a smidgen of interactive, you know,

01:02:37 focus this text box or maybe show this dialogue.

01:02:41 But that's about it, right?

01:02:42 You can learn just Python or you can learn just JavaScript, but like you don't have to

01:02:46 like necessarily learn them in parallel.

01:02:48 Yeah, I think that's a great point, especially when people in the community ask like, I want

01:02:53 to make a blog and I need to learn Django.

01:02:55 That's fine, but you can actually use static sites and GitHub, right?

01:02:59 And so you don't actually have to learn Django per se.

01:03:02 So I would definitely really look at what you're building and then try to choose the right

01:03:07 tool because it's easy to overdo it.

01:03:10 All right.

01:03:10 Maybe it's Netlify and Pelican or something.

01:03:11 Yeah.

01:03:12 Yeah, exactly.

01:03:13 Yeah, exactly.

01:03:13 Yeah.

01:03:14 Cool.

01:03:14 All right.

01:03:15 Well, that was a lot of fun to talk about those.

01:03:17 Let me ask you both the two questions before we get out of here, though.

01:03:20 If you're going to write some Python code, Bob, what editor do you use?

01:03:24 VS Code?

01:03:25 Vim.

01:03:25 Vim?

01:03:27 It's still Vim.

01:03:28 Yeah.

01:03:29 It's just habits.

01:03:30 Yeah.

01:03:30 Yeah.

01:03:31 Cool.

01:03:31 Julian?

01:03:32 Well, I was going to say Vim because that's just what I use.

01:03:36 But look, if I got to choose some other one, I'd actually stick with Notepad++.

01:03:40 I actually really enjoyed that.

01:03:42 Yeah, that's cool.

01:03:43 And I guess I'll throw mine in there as well.

01:03:45 PyCharm.

01:03:46 That's not a huge surprise to people.

01:03:47 Now, notable PyPI package.

01:03:49 I mean, we explored probably over 100 different PyPI packages for the various parts of this and the dependencies and whatnot of all the stuff that we interacted with.

01:04:00 So, there's got to be some that you're like, I didn't even know about this.

01:04:03 And it's really cool.

01:04:04 Bob, you want to go first?

01:04:06 I guess the question for this episode is notable PyPI packages that's not mentioned before.

01:04:12 So, I cannot go on with Django.

01:04:14 Yeah, it could be one that you mentioned before.

01:04:16 Yeah, but Django would be a bit not a surprise.

01:04:20 Now, for example, for web scraping, right?

01:04:23 Two weeks ago, we had a live code challenge and we were scraping some PyCon Spain website data and beautiful soup, right?

01:04:31 It's a great package that makes it easy to traverse the DOM.

01:04:36 And yeah, I'm still happy with that package.

01:04:38 It's very easy to use and gets the job done.

01:04:41 Yeah, and if you want to keep it short, you could pip install BS4.

01:04:44 Yeah, even shorter.

01:04:45 Exactly.

01:04:47 Julian?

01:04:47 It's actually got nothing to do with web stuff because Flask would be a no-brainer for me here.

01:04:52 But one of the ones that I've used time and time again, especially at work, has actually been PXpect.

01:04:58 You guys heard of that?

01:04:59 I haven't heard of that, no.

01:05:00 It's a little automation library or module.

01:05:03 It's pretty much the main function is to automate interactive processes that provide predictable output.

01:05:11 So, think Telnet, SSH, Git and everything like that.

01:05:14 So, you can automate what's going to happen because you know what your response is going

01:05:18 to be when you SSH to a server.

01:05:20 You know that the password prompt is going to come up.

01:05:23 So, you can code in.

01:05:24 Okay, when you get this exact prompt, now what do you do?

01:05:28 And it's really cool.

01:05:30 There's a whole, obviously, bunch of documentation on it.

01:05:32 But that's a library module I really like.

01:05:35 Yeah, that's really cool.

01:05:36 It does SSH, FTP, Telnet, all sorts of cool stuff.

01:05:40 I love it.

01:05:41 See, this is why I asked this question because I learned something every time.

01:05:45 The one I'm going to throw out there is unsync.

01:05:48 So, I talked about unsync before.

01:05:51 It basically unifies all the different ways of doing asynchronous programming in Python and puts the async and await interface on it.

01:05:59 And it's beautiful because it's only 126 lines in a single Python file.

01:06:05 And yet, it basically fixes most of Python's async API.

01:06:10 It's unbelievable that happens in such a small amount of effort.

01:06:13 So, really love that one.

01:06:15 And if you're doing async programming, check that out.

01:06:17 Yep.

01:06:17 All right, guys.

01:06:18 Thank you for being here.

01:06:19 Julie and Bob.

01:06:21 Thank you.

01:06:21 It's good to be back, Mike.

01:06:22 Thank you for having us again, man.

01:06:23 Yeah, yeah.

01:06:24 Thanks for writing this course with me.

01:06:25 We all learned a lot.

01:06:27 And it was fun to share with everyone a little bit.

01:06:28 Cheers, man.

01:06:29 We'll see you next time.

01:06:30 Cheers.

01:06:30 Yep.

01:06:30 Bye.

01:06:30 This has been another episode of Talk Python to Me.

01:06:34 Our guests on this episode were Bob Bilderbos and Julian Sequira.

01:06:38 And it's been brought to you by Ting and Linode.

01:06:40 Ting is the fast mobile network custom built for technical folks.

01:06:44 Use their savings calculator to see exactly what you'd pay.

01:06:48 Visit python.ting.com to get a $25 credit and get started without a contract.

01:06:54 Linode is your go-to hosting for whatever you're building with Python.

01:06:57 Get four months free at talkpython.fm/Linode.

01:07:01 That's L-I-N-O-D-E.

01:07:03 Want to level up your Python?

01:07:05 If you're just getting started, try my Python Jumpstart by Building 10 Apps course.

01:07:10 Or if you're looking for something more advanced, check out our new async course that digs into

01:07:15 all the different types of async programming you can do in Python.

01:07:18 And of course, if you're interested in more than one of these, be sure to check out our

01:07:22 Everything Bundle.

01:07:23 It's like a subscription that never expires.

01:07:25 Be sure to subscribe to the show.

01:07:27 Open your favorite podcatcher and search for Python.

01:07:29 We should be right at the top.

01:07:31 You can also find the iTunes feed at /itunes, the Google Play feed at /play, and the

01:07:36 direct RSS feed at /rss on talkpython.fm.

01:07:40 This is your host, Michael Kennedy.

01:07:42 Thanks so much for listening.

01:07:43 I really appreciate it.

01:07:44 Now get out there and write some Python code.

01:07:46 I'll see you next time.

01:08:07 Thank you.

Back to show page
Talk Python's Mastodon Michael Kennedy's Mastodon