Latest / Talk Python To Me / #224: 12 lessons from 100 days of web
Transcript
- 0:00Back in May of 2018, Bob Belderbos, Julian Sequira, and I started what would turn out to be a nine-month
- 0:06project. We wanted to create a dedicated 100 days of code course specifically for Python web
- 0:12developers. Much of what we created for that course, we did have prior experience with,
- 0:17but with that many different topics, much of it was also new to us. On this episode,
- 0:22we teamed up to distill the lessons, tips, and tools we found interesting on that journey into
- 0:27a quick list of cool tips and techniques. We hope you find something new and useful.
- 0:31This is Talk Python To Me, episode 224, recorded July 29th, 2019.
- 0:36Welcome to Talk Python To Me, a weekly podcast on Python, the language, the libraries, the ecosystem,
- 0:55and the personalities. This is your host, Michael Kennedy. Follow me on Twitter where I'm at,
- 1:00M. Kennedy. Keep up with the show and listen to past episodes at talkpython.fm, and follow the
- 1:05show on Twitter via at Talk Python. This episode is brought to you by Ting and Linode. Please check
- 1:10out what they're offering during their segments. It really helps support the show. Bob Julian,
- 1:14welcome back to Talk Python To Me.
- 1:16Thank you.
- 1:16Good to be here, Mike.
- 1:17Nice to be here.
- 1:18Yeah, it's good to have you both here. We kicked off our acquaintanceship way back. I can't remember
- 1:24which episode it was. It was quite a while ago when we talked about this 100 Days of Code project
- 1:29and journey that you all had been on. And actually, it's turned out to be quite the journey from there
- 1:36as well, right?
- 1:36Oh, yeah. Just nonstop. I think it was episode 140 as well.
- 1:40Yes, it was 140. Thank you.
- 1:42100 Days Survivors. It was quite a hardship.
- 1:46Yeah. So, back then, you guys had been going through 100 Days of Code and documenting it and
- 1:51blogging about it. And then, you know, you came on the show to talk about it. And after that show,
- 1:56we were sitting around talking like, you know, this is really cool. There's not a whole lot to support
- 2:00people specifically in Python to do it. So, you guys and I, we all teamed up to write the 100 Days
- 2:06of Code course that we released last year. And that was really fun and people seemed to like it. So,
- 2:12we wrote the 100 Days of Web in Python course. And that was quite the journey as well and recently
- 2:19released that. So, this show is going to be based on stuff that we take from those experiences.
- 2:26And I want to be clear. I don't want this to be just like an infomercial about the course. I want
- 2:30us really just to focus on the technology. But when we created these courses, this is like,
- 2:36it took us nine months to write that 100 Days of Web course. And some of that was just the effort of
- 2:40recording. But a lot of it was research and polishing ideas and like understanding things better,
- 2:45right?
- 2:45Oh, without a doubt. The amount of tech that and skill that I had to develop in order to teach it
- 2:52was insane. There were so many topics that I just, I knew a tiny bit about, but not enough to actually
- 2:59build something usable and something I could teach. So, yeah, a lot of that time, I would say 80% of that
- 3:05time was actually learning and trying to figure stuff out.
- 3:07Yeah.
- 3:08Bob?
- 3:08And there were some very big topics like JavaScript and Django. And we had to break them down in four
- 3:15day segments, which was a challenge in itself.
- 3:17Yeah. Well, I think part of the challenge of anything like this, and especially the web,
- 3:22is I don't really know when this tipping point occurred, but it felt to me like for quite a while,
- 3:28it was pretty straightforward. There were some choices you had to make if you wanted to write
- 3:32a web app in Python. Like, am I going to use Django? I'm going to use Flask. Maybe I'm going to use Pyramid
- 3:38like Michael. I really like that framework still. And now, now you look at the list of like new and
- 3:46upcoming frameworks. There's like a new web framework every month, at least. It's crazy. So, you know,
- 3:52it's not a surprise that we don't know all these off the top of our head because it's hard to keep up
- 3:57with all of them. And then there's always the, well, that's only been out for a month. Like if I learn it,
- 4:01is it going to actually be around like two months from now? Right. So it's, there's just,
- 4:05do you guys get the sense that the web is kind of blown up? And then, you know, that's only the
- 4:09Python framework, right? We've got JavaScript, we've got databases, we've got like, there's a lot
- 4:13of axes on which that happens. That's exactly right. I hit the, I actually hit that issue recently at
- 4:17work where, you know, I'm trying to create a web app, but did I use Flask or was I going to use,
- 4:22you know, Django? And then wait, what sort of interaction did I need on there? What sort of
- 4:28JavaScript do I need to learn? Oh, wait, do I need jQuery? You know, it just, the list went on,
- 4:33you know, how am I going to deploy it? Is it going to be a static site? And yeah, it's just,
- 4:38it'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
- 4:43had. And so when we went through this course, we all learned a bunch of stuff. And basically it's made
- 4:48up of roughly 24 four day little projects. And each one of them is generally a separate technology and
- 4:56generally standalone. And I said, I don't want this to be an epimertial about the course. So I want to
- 5:01really point out that this is all, every bit of this is, we're going to talk about is in a GitHub
- 5:06repository. And each section has its own little bit with its own readme. So if you want to go play with
- 5:11that, the GitHub repo is open and free. And we'll talk about like where each one of these topics lives
- 5:16in the GitHub repo. And I'll be sure to put that in the show notes as well. So with that in mind, Bob,
- 5:23you want to kick us off with the first topic that you got out of the course that you think is
- 5:27interesting for Python web devs? Yeah, sure. And I start right off the bat with APIs and API star.
- 5:33It's by the same author of Django rest. So I chose that framework as it's relatively new. And knowing
- 5:42the author, I expected to have sensible defaults. And it had was a fun little project that makes it very
- 5:51easy to build your APIs. I got pretty quick results. I also needed some test data for which I used
- 5:58Macaroo, which is a service or website that makes it very easy to get fake data. And combining the two,
- 6:06yeah, became an interesting project where I think I use some car data and build an API around it.
- 6:13One of the challenges though, that I saw when we deployed the app is that there were some breaking
- 6:19changes. So yeah, one warning when you use top notch open source off the shelf products that they might
- 6:27change and they might change rapidly. So I think in the end, we had to pin the version in the requirements.
- 6:34So to make sure that people weren't hitting those issues.
- 6:37Absolutely. And API star is really cool. It's by Tom Christie. And it has changed a lot, actually,
- 6:44even since, since we wrote the course. And that's, you know, that's just the way the way it goes.
- 6:49That's what I was sort of hinting at not specifically thinking of API star, but there's a ton of these
- 6:54projects 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
- 6:59also challenging to figure out which one is going to gain the popularity and energy because they ebb and
- 7:04flow. But yeah, it's really interesting. I love this the way that it works. One of the things that you introduced
- 7:11me to here that I found super interesting is a great service for fake data. Because, you know, as a course
- 7:20developer and trainer, having fake data is awesome, because you don't want to use real data, but you want to have
- 7:25realistic data. But, you know, there's not that many trainers or course developers, right? But almost everyone has to have a
- 7:32prototype app. And you often have to build the app before you have the data, because the app is going to collect the
- 7:37data, right? And so in order to build out the UI and the API and all that stuff, it's really good to have
- 7:43realistic data. So tell us about this place where you got the data from on that.
- 7:46Yeah, it's muckerrule.com. And it has 143 data types, as we speak. And it's broken down in location,
- 7:55commerce, advanced, personal, and the VIN number. And yeah, you just pop them in the field names,
- 8:12and then you can download it in CSV, JSON, tab limited, SQL, Cassandra, Firebase, Excel, XML, like all
- 8:20these useful data formats. And it generates a file. And then yeah, you can just load it in and start
- 8:27using it. It's really cool.
- 8:28Yeah, you named off some data types. And one of them was like car VIN, vehicle identification number.
- 8:32And that's like this big, long, specific thing. But it literally generates reasonably valid looking
- 8:38VIN numbers, not just random values there, but like actually what you would expect in terms of
- 8:43number of character. Yes, exactly. And it has that stuff for like medical bits. And like,
- 8:48it's really quite interesting, all the data sources that it pulled from.
- 8:52Yeah, indeed. And if I look at the API class, then that literally translates to the data. So I have a car
- 8:58class with ID, manufacturer, model, year, and VIN. So it made it relatively easy to build an API on top of
- 9:06it. Yeah, that's cool. So if you're out there building something, and you need data for your API
- 9:10or web app or whatever, Macro, that's pretty cool. And one thing I also wanted to highlight in this
- 9:16section is PostPen. It's a GUI to test your API. So that's another thing. I used it before, but I guess
- 9:24I became better at it because I had to use it again. And yeah, it's very convenient to test your API and
- 9:30get and post requests from GUI. Yeah, you can do it from your dev tools. But Postman is so nice. It lets
- 9:38you set the headers just right. It lets you do all the ACP verbs, you know, post, delete, things like
- 9:45that. For Talk Python, I have a whole suite of APIs I have to maintain for most of the courses. And I have
- 9:52a whole like segment of saved like development and production stuff in Postman for testing that and
- 9:59make sure it all works. And yeah, I definitely recommend Postman as well. Yeah, awesome. All
- 10:03right, Julian, you want to talk about this next one? Like I'm really excited about that. I just can't
- 10:07believe how much we get out of this next one here. Okay, so I'm really excited about this one. This is
- 10:12Netlify. Sounds a bit like Netflix, but it's Netlify. It was a static site generating deployment
- 10:21website. It's just like a jack of all trades. I absolutely loved it. And the funny thing is,
- 10:26as we touched on before, I knew nothing about this. I didn't even know it existed before this course.
- 10:31As we were planning the course, you showed me this, Mike. You said, hey, if you're doing something on
- 10:36static sites, check this out. Yeah, originally your goal was to just cover static sites. And like,
- 10:40what do you use, Pelican or something like this? Yeah, Pelican. Yeah, that's right. And I go,
- 10:44if you're doing Pelican, you got to check out Netlify because that looks super interesting.
- 10:48And I thought, oh, what is this? What's this thing Mike's pointing me to? And when I went and checked
- 10:53it out and actually had a go, it was fantastic. So to give anyone who's listening the general overview
- 10:59is it's this amazing tool where you write your static site in GitHub as you normally would or whatever.
- 11:07And once you have it built in there using Pelican or Jekyll or Hugo or whatever else you want to use,
- 11:14you then point Netlify at your GitHub repo. So there is a little hook in there that
- 11:20links into your repo and it just monitors your repo. It's this continuous delivery or continuous deployment
- 11:27type tool where once it detects a change in your GitHub repo, it'll build your site for you
- 11:35and deploy it on the net for you. So just completely hands off. You don't have to do a thing. And that was
- 11:42probably one of the most satisfying parts of the course was when I was demonstrating that or recording it.
- 11:47There was that moment of fear where I thought, oh, is it going to work? Please work. And then it just worked.
- 11:53So 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:02And yeah, it's just, it's live up on the net. They give you a free URL.
- 12:07So 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:14That's all extra. But from a free base standpoint, you can run your static website on the net using Netlify.
- 12:23And it was really cool. I really enjoyed it.
- 12:25Yeah. 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:34Like you can just git push Heroku and it takes your app and figures out how to run it.
- 12:39Like Netlify is that for purely static sites.
- 12:42Yeah, 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:52It actually tempted me because we use Pelican for PyBytes. That's our static site framework of choice for PyBytes.
- 13:00So 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:08Because I know Bob's mentioned that. He uses it for his blog. And then I've heard good things about Hugo.
- 13:12And 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:23Because it was one of the most satisfying things.
- 13:26Yeah, it's super cool. And I can't believe what they offer for free, right?
- 13:30I mean, just to be clear, we have no affiliation with Netlify. They didn't pay anything for this.
- 13:35Just like, this is really cool. I can't believe that it's actually available.
- 13:39Like, so custom domain, HTTPS certificates, continuous deployment through GitHub, all of that for free. It's crazy.
- 13:47Yeah, it's a beautiful tool.
- 13:48Awesome. Yeah, so if you've got anything static, that's definitely the way to do it. That's cool.
- 13:52All right, so I guess I'm up next for the next one here.
- 13:56One of the things I wanted to focus on was just foundational HTML.
- 14:00Because I want to hear your two opinions on this.
- 14:03Because to me, I for a long time didn't want to get into web development.
- 14:07Because I knew I was a good developer, but I didn't feel like I was artistic in the graphical visual sense.
- 14:14You know, like I was always like bad at art in school or whatever.
- 14:18So I felt like I'm going to have a hard time designing stuff.
- 14:21So HTML and CSS and all that like was until I took the time to sit down and properly learn it.
- 14:27It was actually not a huge roadblock.
- 14:29But so I'd always try to find like, what is the way I could do this without really writing HTML?
- 14:34Like what little widget will generate the thing that I want to work?
- 14:37Like the calendar, because I don't want to write.
- 14:39You know what I mean?
- 14:40Like that was me for a long time.
- 14:41But then once I learned HTML and CSS super well, like it became this thing that I was happy to do.
- 14:46And I felt like it was made like getting into this stuff much easier and took away all that hesitation.
- 14:51So I thought it was great.
- 14:52So I wanted to talk about like the history of HTML.
- 14:55And there's just some stuff that surprised me there that I thought I would cover here.
- 14:59So 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:14That was cool.
- 15:16It's cool.
- 15:18But oh my gosh, can you guys believe what those sites used to look like?
- 15:21Trash.
- 15:22I don't want to know.
- 15:23It's so weird.
- 15:24I 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:38And it's just like, wow.
- 15:39Yeah.
- 15:40Really?
- 15:4015 minutes.
- 15:41Okay.
- 15:41And now Google is a highly interesting technical foundation, but Yahoo is like a directory listing.
- 15:47Like you could have finished it up in another hour.
- 15:49I mean, it was really interesting, but that's all it was.
- 15:52And so some of the things I found interesting as well is back in 1996, you couldn't use spreadsheets.
- 15:58Spreadsheets.
- 15:59Sorry, that's for style sheets.
- 16:01Style sheets were not introduced until 1999.
- 16:04Wow.
- 16:05Wow.
- 16:05I didn't know that.
- 16:06Yeah.
- 16:06All the HTML attributes had to just be set in the DOM, like over and over.
- 16:11Yes, exactly.
- 16:12Right.
- 16:12Like you would for like a newsletter because they don't know that style sheets.
- 16:15So that was crazy.
- 16:17And then the other thing was, if you look at the history of HTML, like there was a lot
- 16:21of rapid growth from 1990 to 2000.
- 16:24There was a bunch of versions, you know, every couple of years or something like that.
- 16:28In 1999 was HTML4.
- 16:32In 2000 was XHTML, which is an attempt to make all HTML documents formal XML, like a superset
- 16:42of XML.
- 16:43So every element had to be closed.
- 16:44Every attribute had to have a value with quotes for the value and things like that.
- 16:49Right.
- 16:49So that was 2000.
- 16:51The next change to HTML was 14 years later.
- 16:55So HTML didn't change for 14 years, even though this is like basically on the heels of the
- 17:01dot-com boom and everything.
- 17:02Like what happened there, right?
- 17:04So in 2014, HTML5 came out.
- 17:07Now I know there's probably like super minor little changes, but like no important changes
- 17:11happened between 2000 and 2014, literally in the specification.
- 17:16That's one of the things I actually kind of off topic, but what I love about this is that
- 17:21you did all this research, discovered all this stuff, and then I got to go and learn
- 17:27it through you.
- 17:27So this is all cool stuff because, and I hate to say it, Mike, but you know, back in those
- 17:33dates you were talking about, I was still pretty, I was still in school.
- 17:36I'm sorry.
- 17:36Well, you could have been one of those like kids that started a startup and dropped out
- 17:41of middle school.
- 17:41Could have.
- 17:44No, just kidding.
- 17:44Should have.
- 17:45Could have, should have, right?
- 17:46Yeah.
- 17:47What are you doing?
- 17:47I'm going, I'm going to go to college next year.
- 17:50Yeah.
- 17:50I'm going to take my yacht on a tour because my business is doing pretty well.
- 17:53One day.
- 17:54I'll push that on my kids.
- 17:56No, I'm kidding.
- 17:57Yeah.
- 17:57This portion of Talk Python To Me is brought to you by Ting.
- 18:03Let me tell you about Ting, a new mobile service available in the US that's targeted developers
- 18:07and other technically savvy folks.
- 18:10First of all, their average customer only pays $23 a month, but they're no discount provider.
- 18:14Their service runs over T-Mobile's and Sprint's fast nationwide network.
- 18:19If you don't use that much data because you're usually on Wi-Fi, like many of you are, then
- 18:23Ting will save you a ton of cash.
- 18:24But don't worry.
- 18:25You can still use as much data as you like for just $10 per gig.
- 18:29One mobile feature I use all the time is tethering.
- 18:31And 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:40iMessage or WhatsApp.
- 18:41Think about it.
- 18:42No contracts and super clear and fair billing.
- 18:46Visit python.ting.com.
- 18:47That's python.ting.com.
- 18:50And check out their savings calculator.
- 18:52Enter your usage and see exactly what you'd pay.
- 18:55Use that link and you'll get a $25 credit to try them as well.
- 18:58That's python.ting.com.
- 19:00Or just click the link in the show notes.
- 19:03All right, Bob, you're up next.
- 19:05No, you had to commence on HTML, actually.
- 19:07Well, I was pretty happy that you covered it because HTML is so fundamental for a web developer.
- 19:12Because when I look at my Django workflow, I mean, part of my time, I'm actually writing
- 19:17HTML in the template.
- 19:18So it's very important.
- 19:20Also, as well as CSS.
- 19:21It's always something that needs to be styled, even if you're using a framework.
- 19:25So it's kind of, it's very basic knowledge that web developers should have.
- 19:29The other thing I'm really astonished by is how far we've come.
- 19:34The other day, you needed a progress bar.
- 19:36And now you can have this predefined tag, progress, right?
- 19:39So no JavaScript, no scripting.
- 19:41You can just use a progress tag and give it like a numeric value.
- 19:45And you have your, that's pretty cool.
- 19:47That is so cool.
- 19:49Yeah.
- 19:49We really have come a long ways.
- 19:51Yeah, but you don't always see JavaScript.
- 19:53And I do agree that CSS is actually of those skills.
- 19:57If you can learn the basics of CSS, like that is like kind of a web superpower, right?
- 20:01That really unlocks a lot of things.
- 20:03Another part, though, is JavaScript some of the time, right?
- 20:06Yeah.
- 20:06No, you cannot escape it.
- 20:08And you better learn JavaScript.
- 20:11A good part, actually, because most of the web is powered by JavaScript.
- 20:15I mean, there's Python, there's the backend always.
- 20:17But every page out there uses JavaScript and some of them a lot.
- 20:22So the challenge I had, though, I mean, JavaScript is a whole language.
- 20:26And I needed to cover it in four days.
- 20:28So that was tough.
- 20:29So I really tried to become an essentialist and focus on the essential part.
- 20:35So the data types and a little bit of ES6, actually, as well, because that's now important to know.
- 20:42Yeah, that's basically version six of JavaScript.
- 20:44Right.
- 20:45Right.
- 20:45ECMAScript six.
- 20:46Yeah.
- 20:46Right.
- 20:47So we have arrow functions and destructuring, map and filter.
- 20:51So it's likely that you're going to find it.
- 20:53So I did cover some ES6.
- 20:55And also within this context, I wanted to talk about React, which is one of the major frameworks in JavaScript.
- 21:02And again, that was a pretty steep mountain to climb.
- 21:08So 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:16And you have to keep state as well as use a user interface.
- 21:20So I decided to build a game, which was not easy.
- 21:22So I decided to build a game, which was not easy.
- 21:24But actually, it did give me a way to break a huge topic down into 16 or so segments.
- 21:31That's cool.
- 21:31What was your thought of React coming from a Python background?
- 21:36Like, do you like it?
- 21:37What's the general programming model feel like?
- 21:39It was a bit confusing at first.
- 21:41But then I did start to appreciate it for its design philosophy, especially how it treats mutability.
- 21:49So I did end up liking it, yes.
- 21:52But it took a little bit to get into.
- 21:54There's a lot of moving pieces.
- 21:55Yeah.
- 21:56As a web developer, it feels a little weird to me because I always tried to aim for, like, separation of concerns, right?
- 22:03So you've got your style sheet, you've got your JavaScript, and then you've got your HTML.
- 22:08And I've always aimed to have, like, the HTML depend as little as possible on the other two and so on, right?
- 22:15Like, try to keep those focused.
- 22:16And here, it's like you embed the HTML in the JavaScript little component bits.
- 22:22It seems a little funky to me.
- 22:23Yeah, JSX, right?
- 22:25The new syntax.
- 22:27Yeah.
- 22:27That's a little weird at start.
- 22:29I agree.
- 22:30Yeah, I guess if the tooling supports it, right?
- 22:32If the tooling treats that little HTML block as HTML, then it's not so bad.
- 22:36But it's definitely a mind shift, yeah.
- 22:38And there are tools to bootstrap your app.
- 22:40For example, I used Create React app, which I think is from Facebook, who invented the whole framework.
- 22:46And that did help because you get all your defaults in place.
- 22:49And you can just npm start and you have a basic structure in place.
- 22:55So that really helped.
- 22:56Yeah, that's cool.
- 22:57Yeah, a lot of these front end frameworks, JavaScript frameworks have like little bootstrappy scaffolding CLIs for them.
- 23:04That's cool.
- 23:05So just because I'm a complete noob with JavaScript, right?
- 23:09And I'm trying to learn it now.
- 23:11So you're, and this is an interesting point from a teaching standpoint.
- 23:15You had to squeeze JavaScript into four days, which is just seems unthinkable.
- 23:20You had to really whittle that down to people who don't know it, right?
- 23:25Teaching it from scratch.
- 23:27And so can I learn this myself from zero?
- 23:32Yes, you can.
- 23:32Okay.
- 23:33Now, so this is actually more for me than anyone else.
- 23:35I mean, it assumes some basic programming knowledge.
- 23:40I 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:49And, you know, if you already know Python or another language, I mean, a lot of stuff sounds familiar, right?
- 23:53I mean, a list or array in JavaScript, you can slice as well.
- 23:58Or, well, you can take an index.
- 24:00You cannot actually slice it.
- 24:02Or you can slice it, but it's dot slice.
- 24:04So it's all very similar, the concepts, but the syntax is sometimes different.
- 24:09Okay, cool.
- 24:10Cool, cool.
- 24:10All right.
- 24:10Julian, you focused a lot on Flask.
- 24:13So you cover one of the plugins for Flask called Flask Login, right?
- 24:17Yeah.
- 24:18So this one was more like a bucket list item for me.
- 24:21For ages, I've wanted to deal with how to log in to a website using Flask.
- 24:27And I got to tell you, Mike, this one, I wanted to rip my hair out by the end of it.
- 24:32I think it took me a solid month to wrap my head around it.
- 24:35For anyone who's not familiar with Flask Login, the actual Flask Login part is the easy part.
- 24:42Everything 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:52And I'd never dealt with any of that before.
- 24:55So this was one of the major learning points for me in this whole challenge, this 100 days.
- 25:00But it was the most satisfying thing to figure out.
- 25:03When you look at my page, as you said, Mike, it's HTML from back in 1996.
- 25:09I think my page looked even worse than that.
- 25:12But to see a logged out and a logged in sort of view, I think I had a few beers that night to celebrate.
- 25:20Nice.
- 25:22Yeah, it was one of the most satisfying things because it's actually really simple once you get your head around it.
- 25:29There is a whole lot of SQLAlchemy you have to learn or I have to learn.
- 25:34And I teach this before you get into the Flask Login.
- 25:37And that was the hardest part for me, as I've just said.
- 25:40But if you can get through that and if you know that stuff, then the actual Flask Login is pretty easy.
- 25:46I think one of the greatest parts of it is, you know, as with Flask, there's a lot of stuff with decorators.
- 25:53And 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:04Or is it?
- 26:05No, no, what is it?
- 26:06It's Login Required.
- 26:07Login underscore required.
- 26:08And you throw that on any of your pages, any of your routes.
- 26:12And if someone tries to browse that page, it'll check to see if they're logged in or not.
- 26:17And it was as simple as that.
- 26:19You sort of had to do nothing else to your site to be able to do that, to get the Login page to work.
- 26:26That was probably the most satisfying part of using Flask Login.
- 26:29So that was a really good one.
- 26:31And 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:38And once you implement a Logout page to create users so that people can actually register an account,
- 26:45tie all that in with an SQLAlchemy database back end, and this thing just is beautiful after that.
- 26:51That's cool.
- 26:52Yeah, it sounds like a really nice way to do it.
- 26:53And these plugins for Flask are definitely cool.
- 26:55It also, if you're using Flask anyway, there's a high probability if you're using SQLAlchemy also, right?
- 27:02Like Flask is a micro framework and doesn't come with some ORM.
- 27:06So as long as you're using a relational database, the chances are very high you're using SQLAlchemy.
- 27:10I mean, you could be using something else like there's PeeWee ORM, which is nice.
- 27:14You might be using something like MongoEngine for MongoDB.
- 27:17But, you know, most likely SQLAlchemy.
- 27:19So you're already kind of in that space, right?
- 27:22So here's just the user aspect being handled for you.
- 27:25Well, 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:40There's a massive leap there that you have to make.
- 27:43So get the SQLAlchemy down.
- 27:45That's the first part.
- 27:46Then work on your plugins.
- 27:48Yeah, absolutely.
- 27:49I 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:55Like I create the one file.
- 27:56I create app.py.
- 27:57I call the Flask thing to create the app.
- 28:00I use that to decorate a function.
- 28:02Hello, world.
- 28:02App.run.
- 28:03We're good, right?
- 28:04But in reality, there's all these other things to it, right?
- 28:07There's like the database access and the structure and the factoring and the testing.
- 28:10And there's more to it than initially meets the eye when you create these things.
- 28:14It's almost like a false sense of security.
- 28:16Yes.
- 28:17Yeah, 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:22Like Flask sells itself as like, oh, it's just this one file.
- 28:24But like if you really create an app that's just one file, like a whole website, like you're probably doing it wrong.
- 28:30You know what I mean?
- 28:30Like it's so important.
- 28:32It's kind of like encouraging you to not do the best thing.
- 28:34So anyway, it's still – it's a great framework.
- 28:36I like it.
- 28:36All right.
- 28:37I guess that puts me next here.
- 28:39So the next thing I want to talk about is also Flask.
- 28:42And this one is called Court.
- 28:45So this puts together a couple of ideas that I find really interesting in Python.
- 28:49You know, a lot of times you hear people tell you that like asynchronous programming in Python is super complicated.
- 28:57And it's basically broken.
- 28:58And like you can't really use it anyway because of the GIL and stuff like this.
- 29:02And I did a lot of thinking about this and a lot of research on this.
- 29:05And actually, I think as of Python 3.5 and beyond, like that's not really true.
- 29:10It's not really – I don't think it was totally true before and it's definitely not true these days.
- 29:14I think asynchronous programming in Python is really interesting.
- 29:17So I'll talk about that in a second.
- 29:19But also things like Flask and Django and Pyramid, none of those support async programming, which is odd.
- 29:26I mean, it strikes me as odd.
- 29:27Does it strike you guys as odd?
- 29:28Yes, a little bit.
- 29:29Yeah, I'd expect so these days, but it is weird.
- 29:32Exactly, right?
- 29:33Like what web apps basically do is they talk to other systems and like coordinate it and then they wait while that happens, right?
- 29:40Like you make a request.
- 29:42It talks to the database.
- 29:43It waits.
- 29:43Maybe it has another question for the database after it figures out what user it is.
- 29:47It's going to ask like, well, what's in this category?
- 29:49They post it over to me and it waits for that.
- 29:51And maybe it's going to call an API and wait for that.
- 29:53Maybe it's a cache and it'll call Redis and wait for that.
- 29:55And it's going to put those answers together in a template and give it back to you, right?
- 29:59Like it's all about coordinating waiting basically is the way I see the web.
- 30:02And yet that's the perfect scenario for asynchronous programming.
- 30:07Like let you do other stuff while you're waiting on the database because you're actually not doing any work.
- 30:11You're just waiting.
- 30:12But because of the history of the way these frameworks are built up, they're all based on WSGI.
- 30:16WSGI is like basically single thread requests.
- 30:19There's not a great way to do it.
- 30:20So if you do want to do that, you have to pick one of these many plethora of these brand new frameworks.
- 30:26Or you could pick this thing called Cort, which is cool.
- 30:29And I've covered this on Talk Python before.
- 30:31But Cort is basically a API and plugin level compatible thing with Flask.
- 30:39But it supports asynchronous methods and async and await and all that kind of stuff.
- 30:44So that's pretty cool.
- 30:44So you just basically replace the word Flask with Cort.
- 30:48If it's a lowercase Flask, it's a lowercase Cort.
- 30:50If it's an uppercase F on the Flask, it's uppercase Q on the Cort.
- 30:54And like that's pretty much it.
- 30:55And things like Flask login and all that stuff still work with it.
- 30:59And 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:08And within there, you can await your database call.
- 31:11You can await your Redis key lookup and things like that.
- 31:14That's nice.
- 31:15Oh, that is cool.
- 31:16Yeah.
- 31:16So it's really nice.
- 31:18It's interesting if Flask, sorry, if Cort is going to be its own thing in the long term.
- 31:22I 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:31Like, could we just make Flask async?
- 31:33And Flask does have async on its roadmap.
- 31:36I know there's a conversation about Django's async roadmap and things like that.
- 31:40So, you know, these other main frameworks are working towards that, but they're already existing.
- 31:44I don't know.
- 31:45It's a challenge, but there's a bunch of really interesting things there.
- 31:48And 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:56Like we've got threads, we've got processes, we've got asyncio, which uses the async and await keywords.
- 32:02But for some reason, threads, you can't use async.
- 32:05You can't await a thread, which is weird because you should be able to.
- 32:08Things like that.
- 32:09But there's this thing called unsync.
- 32:11And unsync lets you put a decorator on all of your asynchronous methods.
- 32:18And it will figure out which type of asynchronous programming or execution is appropriate for it.
- 32:24So sometimes it'll use threads.
- 32:26Sometimes it'll use asyncio.
- 32:27Sometimes it'll actually create subprocesses.
- 32:29But your program model is all the same.
- 32:32It's just async and await straight across the board.
- 32:34It's a beautiful library.
- 32:36I just love that thing.
- 32:37And 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:44It's definitely cool.
- 32:45So 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:52Great.
- 32:52Yeah, that's a fun one.
- 32:53Speaking of Django and its async roadmap, Bob?
- 32:57Speaking of Django, I wanted to ask you, is the async on the roadmap?
- 33:01Anyway, if it's not, it's still my favorite.
- 33:06So a big chunk.
- 33:08Yeah, the Django guys are talking about it.
- 33:09They're playing it.
- 33:10It's just not there yet.
- 33:11I'm sure they are.
- 33:12Yeah, I'm a big fan.
- 33:15And 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:26So also Django is a very big topic and people find themselves with a steep learning curve.
- 33:33So the best way to go is to build a very simple CRUD app.
- 33:38So create, read, update, delete.
- 33:41And I built a quotes app with one model.
- 33:45Very simple, but a great opportunity to look into Django's ORM.
- 33:49So if you're not familiar with these frameworks, one of the things they do is get rid of you writing raw SQL.
- 33:57So you can use the object relational mapper or ORM and it makes it very easy to talk to a database.
- 34:04And Django's ORM I really like.
- 34:07I mean, it's very intuitive and the syntax makes a lot of sense.
- 34:10Yeah, and Django is different in the sense that like Julian and I were talking about SQLAlchemy, which we both like.
- 34:16But SQLAlchemy is its own separate thing and you choose to bring it into Flask or Pyramid or something like that.
- 34:21But with Django, it comes with its own like more integrated data access layer, right?
- 34:26Right. That's a great addition.
- 34:27Yeah, because yeah, Flask, you have to set it up separately and usually you go with SQLAlchemy.
- 34:32But Django has all the stuff in the box.
- 34:35It's a complete solution.
- 34:36Also the templating, I think for Flask, you would use Jinja and Django has its own templating engine.
- 34:44So Django is great if you want to have a complete solution out of the box, but then it is opinionated.
- 34:50So some people like it, some people don't.
- 34:52And I do like the decisions they made.
- 34:55What do you like, Django or Flask?
- 34:56What do you think?
- 34:58It's a never-ending battle between you and me.
- 35:01You're Django, man.
- 35:03Fine.
- 35:04Yeah.
- 35:05So another thing I covered was, I mean, always, usually if you make a website, you need some sort of registration and login.
- 35:14So I covered the Django registration plugin, which recently was upgraded to 3.0.
- 35:20Great plugin.
- 35:21If you need to capture emails and do two-way authentication.
- 35:25So you need to send an email, confirmation email for a user to confirm and register.
- 35:31The only thing confusing was that the templates were missing.
- 35:35So I ended up providing them in a zip file.
- 35:37Even so, I would really recommend looking into that plugin, which is called Django registration.
- 35:42And lastly, in this context, I also covered Django REST.
- 35:46As we mentioned before, same author as API star.
- 35:49And 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:58So I use the same quote app.
- 36:00Right.
- 36:00If 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:12Right.
- 36:12Yeah, you basically make a serialization module and that's almost all you have to do.
- 36:18So it makes it really easy.
- 36:20And it has also support for permissions.
- 36:23So I think that's done via some middleware.
- 36:27And yeah, I also plugged in a swagger for documentation.
- 36:31And yeah, it was all pretty easy, relatively a few lines of code.
- 36:36So I really liked Django REST framework and I can highly recommend it.
- 36:40That's cool.
- 36:40Do you use Django REST framework in your code challenge platform?
- 36:43Yeah, good question.
- 36:44I actually not.
- 36:45Just use Django, but not Django REST, right?
- 36:47Yeah.
- 36:48Django made that pretty easy to do.
- 36:50We just manually made some API endpoints.
- 36:53Yeah.
- 36:54Yeah, I ended up doing that a lot as well.
- 36:55We 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:02Then we definitely want to use it.
- 37:04Yeah, for sure.
- 37:05I've been down that road.
- 37:07Yeah, another module I want to highlight was SendGrid for emails.
- 37:12Because with the registration plugin, you have to send a verification link.
- 37:18And SendGrid makes it very easy with their API to send emails.
- 37:23So I use that as well in this context.
- 37:25Yeah, the days are a long call and you should set up your own SMTP server and talk to it locally.
- 37:30Using something like SendGrid makes a lot of sense.
- 37:32Yeah, 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:40So it's security concerns.
- 37:42So it's not, that was not a success.
- 37:44Lessons you learn.
- 37:46Why is my email not getting delivered?
- 37:48This portion of Talk Python To Me is brought to you by Linode.
- 37:53Are you looking for hosting that's fast, simple, and incredibly affordable?
- 37:57Well, look past that bookstore and check out Linode at talkpython.fm/Linode.
- 38:02That's L-I-N-O-D-E.
- 38:04Plans start at just $5 a month for a dedicated server with a gig of RAM.
- 38:08They have 10 data centers across the globe.
- 38:10So no matter where you are or where your users are, there's a data center for you.
- 38:14Whether you want to run a Python web app, host a private Git server, or just a file server,
- 38:19you'll get native SSDs on all the machines, a newly upgraded 200 gigabit network,
- 38:2424-7 friendly support, even on holidays, and a seven-day money-back guarantee.
- 38:28Need a little help with your infrastructure?
- 38:30They even offer professional services to help you with architecture, migrations, and more.
- 38:35Do you want a dedicated server for free for the next four months?
- 38:38Just visit talkpython.fm/Linode.
- 38:41Julian, what do you got for the next one?
- 38:44So the next one is actually kind of simple, but again, it was very satisfying, a lot of fun to do.
- 38:50So I did some Heroku deployment on, what was it, day 65 to 68, something like that.
- 38:57And it was really satisfying.
- 39:00So I know with Netlify, I was able to deploy a static site and have it all hosted.
- 39:06But this time I wanted to get my Flask app.
- 39:08And one of the best parts was the Flask app that I was creating throughout all of the course.
- 39:14It's all running local.
- 39:15You know, it's all local on your desktop.
- 39:17So 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:28And they make it really simple.
- 39:30And 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:37And the best part is with your Flask app, they fully support Flask.
- 39:42So you can just deploy it.
- 39:44You link the repo that you've created locally to Heroku.
- 39:48And 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:58So 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:07And that's it.
- 40:08Heroku takes care of the rest.
- 40:09So it's actually really simple.
- 40:11That was part of what I covered in that section of the course.
- 40:15But I also wanted to highlight some of the cool features Heroku has.
- 40:19And again, I'm going to say, I know this sounds like a massive plug for Heroku, but it's not.
- 40:22I just really like what they do.
- 40:24They have a lot of plugins that you can use.
- 40:27I think they call them plugins.
- 40:29Yeah, whatever.
- 40:30We're going to call them plugins.
- 40:31We're going to call them plugins today.
- 40:32So there are two that I wanted to cover.
- 40:35Bob just mentioned one, SendGrid, because we use SendGrid a lot.
- 40:38So again, you can hear that a lot of the stuff we're discussing here, we use actively.
- 40:43So that's why we wanted to cover it in the course.
- 40:45But this SendGrid plugin, it links, the add-on, it links with your SendGrid account.
- 40:52And it's the most minimal amount of code to throw into your code base to then shoot off an email automatically.
- 40:59And it just works really well.
- 41:02So I really enjoyed that, teaching that.
- 41:04In fact, I think the hardest part was making that section take a day, because it was so easy to teach.
- 41:12It was, you know, I was struggling for things to say.
- 41:14I probably should have just sang a song or something.
- 41:17But then the other one I wanted to cover off was Heroku Scheduler, however you want to pronounce that word, scheduler.
- 41:23But it's just essentially cron, and it makes your life so much easier.
- 41:28You don't need to go into any backends and worry about it.
- 41:31It has a nice web interface if you're that way inclined, like me.
- 41:35And it's just super helpful.
- 41:38You can automate so many tasks.
- 41:40You can little parts of your Flask app, whatever you want, with this little scheduler.
- 41:46Literally put in the code that you want it to run every time.
- 41:49And it's just, it's really easy.
- 41:51Really pleasant to use.
- 41:53Really pleasant experience.
- 41:54It's not something you get to say very often.
- 41:55Yeah, that's a great way to describe deployment, right?
- 41:58Like, normally deployment is something that people got to learn a lot about.
- 42:01It's really tricky, and stuff goes down.
- 42:03Like, where are the Nginx logs?
- 42:06It says it doesn't work, but I don't know why.
- 42:08I can't figure out where the logs are.
- 42:10You know, like, so this is really nice.
- 42:12I know there's a lot of people, like you guys, who love platform-as-a-service stuff, like Heroku.
- 42:17But 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:24So, yeah, definitely, if you're inclined towards the platform-as-a-service side, that sounds like a good option for sure.
- 42:30Yeah, definitely.
- 42:31All 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:36And that's database migrations.
- 42:39So, if you're using SQLAlchemy, Mike Bayer created this thing, who also created SQLAlchemy, created this thing called Alembic.
- 42:45And if you're using Django ORM, there's migrations built into that as well.
- 42:51And the idea is that regardless of which one you're using, but I'll talk about SQLAlchemy just to have something concrete.
- 42:57If your SQLAlchemy class structure does not match what your database structure looks like, your app is coming to an abrupt screeching halt, right?
- 43:07Oh, yeah.
- 43:08You're going to get a, you know that, right?
- 43:09You're going to get a 500 error.
- 43:10It's going to say operational error database schema, like this column doesn't exist or something terrible like that.
- 43:16And you'll be like, whoa, that sounds kind of bad.
- 43:19But, 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:26Like, it will no longer talk to the database.
- 43:27It's a problem.
- 43:28So, how do you manage that, right?
- 43:29Like, some people probably, like, evolve the database manually.
- 43:33That sounds a little scary to me.
- 43:36Just 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:42So, what's great with Alembic is you can just point it at your SQLAlchemy models, point it at your database.
- 43:47There's a little bit of configuration to set it up.
- 43:49But then you can just run a command, auto-generate the migration.
- 43:54And it'll look at your classes and it'll look at the database and go, well, this column was dropped.
- 43:57This one was added and this index was updated in this way.
- 44:00And then it just lets you run a command line operation that will automatically transform the database like that.
- 44:07So, one developer makes a change.
- 44:08The other developer checks it out.
- 44:09You know, obviously, that change needs to accompany a migration.
- 44:13So, then they can just run the migrations as they get the new version of the app.
- 44:16You push it to Q&A or staging.
- 44:18You run the migration.
- 44:20And then as part of your deployment, you can just have it always run a migration.
- 44:24And, like, if there's no operations, it just goes, you know, if it's up to date, it just goes, eh, nothing happens.
- 44:29So, we'll just keep going.
- 44:31So, it's a really nice way to make sure that your database constantly stays in sync with your ORM models.
- 44:37Oh, that is really cool.
- 44:38Yeah.
- 44:39And when I first looked at it, I'm like, whoa, this looks complicated.
- 44:42Why is this so hard to set up?
- 44:43Maybe it is.
- 44:44I don't know.
- 44:44There'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:53But once you get it all figured out, it's not too bad.
- 44:55We covered that in day 61 to 64.
- 44:57So, you can go check out the little sample code there.
- 45:00Another alternative is to just not use a relational database.
- 45:03Like, you know, all my stuff, like, in production runs on MongoDB.
- 45:06And MongoDB doesn't have this problem.
- 45:09But it also has basically an ORM, something called an ODM for them.
- 45:12MongoEngine is what I use.
- 45:14And it's basically like SQLAlchemy.
- 45:17It's more like Django ORM, actually, but same idea.
- 45:19But MongoDB doesn't have this problem in general.
- 45:22So, you don't have migrations really there.
- 45:25You can sidestep it that way.
- 45:26But a lot of people want to use a relational database.
- 45:29And if you do, migrations.
- 45:30It's a great way to solve the problem.
- 45:31Ah, that's really cool.
- 45:33And I can see it's, so I'm just on the documentation.
- 45:35And it's actually alembic.sqlalchemy.org.
- 45:39So, yeah, very cool.
- 45:41Yeah, yeah, same organization, same people behind it.
- 45:43Bob, do you guys use migrations, the Django migrations for what you're doing?
- 45:46Yeah, very simple.
- 45:47Make migrations.
- 45:49That makes a file you commit to version control.
- 45:52And then just migrate.
- 45:53And then it syncs it to the database.
- 45:55Works great.
- 45:56Yeah, sounds real similar to the auto-generate feature there.
- 45:58It's cool.
- 45:58All right, Bob, what's your last one?
- 46:00Slackbots.
- 46:02That was one of the most fun chapters I worked on.
- 46:07And, well, we all...
- 46:09Slack is used for all sorts of things, right?
- 46:11Like, people chat with it.
- 46:11But it's also got so many integrations, right?
- 46:14Like, for example, if, like, I have an error on my website,
- 46:18I have a Slack channel that Rollbar will detect the error on my website
- 46:22and then post a message to me on Slack that there was an error on the website, right?
- 46:26And that's like a Slack bot, sort of.
- 46:28Sort of, I guess.
- 46:29But, yeah, there's all sorts of uses for it.
- 46:31Yeah, when people do a pull request or a code challenge repo,
- 46:35we get a notification in our pull request channel.
- 46:38But also, if you think about, like, the general Slack bot, it's super useful.
- 46:42Like, you can set reminders and stuff.
- 46:44So, yeah, bots overall are becoming more popular.
- 46:48So, it's a nice skill to have, I think.
- 46:50And so, yeah, for this chapter, I looked into Slack API.
- 46:56And we made a random book slash command.
- 47:00So, if you type slash book in our Slack, it reaches out to some books API we have for another app we run.
- 47:08And it posts back some random title.
- 47:09You can also do slash book and then user.
- 47:12And you get the last book for the user.
- 47:14So, that's fun.
- 47:15That's cool.
- 47:16And what's nice about these apps is that there's a lot of moving pieces.
- 47:20So, it's not only the Slack API, but you have to call another API to get your data.
- 47:25So, in this case, that was Google Books API, which I think has been around forever.
- 47:29And we had to make a little Flask app for the slash command to actually grab data.
- 47:37So, it was and retrieving data from an API and making an API.
- 47:40And then, before rolling it out, you want to test your local server on the internet.
- 47:46And for that, I used ngrok, right, which is a pretty important tool if you want to, how would I say that?
- 47:55Link your local host to your internet address or make your local host available on the internet, so to say.
- 48:01So, you get this kind of temporary IP.
- 48:03And anybody connecting to that IP is actually talking to your local web server, which is cool, useful.
- 48:10I'm so glad you covered ngrok here.
- 48:12You threw this in here because ngrok is incredible.
- 48:15So, 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:24Locally, over to, like, 88532ff5.ingrok.io.
- 48:30And it actually has an HTTP and HTTPS version.
- 48:33So, at first, I thought, oh, this is kind of interesting.
- 48:36But I've been using this for some incredible stuff.
- 48:39So, for example, when I was developing my mobile apps,
- 48:42I 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:54Right?
- 48:55And, of course, I could drop my firewall and, like, set this up and, like, all.
- 48:58But we just run an ngrok command.
- 49:01You don't need to change firewall settings on either end.
- 49:04It just automatically goes through the internet, through HTTPS, and then right back in there.
- 49:08And you can step through one, step through the other.
- 49:11Another one was I was doing some integration with Gumroad for the purchasing of the PyCharm book that Matt Harrison and I wrote.
- 49:18And we had to do some – there's one option you can buy where you also get a course.
- 49:22And so, it had to, like, create an account and, like, put you in the course.
- 49:24And, like, it wasn't working.
- 49:27So, I put the URL it was supposed to work and it wasn't working.
- 49:29Like, why is this not working?
- 49:30And, like, why don't I just put the ngrok URL in there?
- 49:32And 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:41It is so cool, this ngrok thing.
- 49:43It's definitely underestimated.
- 49:44That's really cool.
- 49:45If you cannot debug something on local host, you're lost, right?
- 49:48Right.
- 49:49I 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:57Like, you can't debug Slack, right?
- 49:59That's their infrastructure out on the internet.
- 50:01But you can actually, like, deeply run and iterate on, like, your local version using ngrok.
- 50:07It's awesome.
- 50:08Yeah.
- 50:08Yeah, okay.
- 50:09I'm excited about that.
- 50:10I got to stop.
- 50:11But, yeah, definitely you found it valuable as well, huh?
- 50:14No, that is cool.
- 50:15So, the whole ngrok thing is amazing.
- 50:17I didn't even know you used that, Bob, in that part of the course.
- 50:20Did you create any other Slack bots other than just the books one?
- 50:24There's one we actually use quite a bit.
- 50:26which is called Karma Bot on our Slack.
- 50:31And if you want to give people credit for contributing to the community, helping each other out, you just use add handle plus plus.
- 50:39And Karma Bot keeps a local database of users' karmas.
- 50:46So, the user then gets extra points.
- 50:49And it's funny how people sometimes react to that gamification.
- 50:53Definitely boost community participation.
- 50:58And, yeah, it's all run by a Slack bot.
- 51:01It's kind of funny.
- 51:02It's a bot, but people kind of treat it as a human at some point, right?
- 51:06That's really one of the most satisfying projects.
- 51:11It's not in the course, but it's on GitHub.
- 51:13We will link to it.
- 51:16That's another example of a bit more elaborated Slack API project.
- 51:20For sure.
- 51:21Julian, you want to wrap up your section with Chuck Norris?
- 51:24Oh, yeah, I do.
- 51:25So, while we're having a bit of fun, this was the most fun I had in the course from an actual fun standpoint.
- 51:33So, what I wanted to do is, I guess I'll give you the quick background.
- 51:36It was Flask, but what I wanted to do was give the users a sort of real-life use case.
- 51:42So, 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:51So, 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:59So, that involves, you know, setting some gets, getting some posts potentially, and then presenting that data.
- 52:06So, doing something with it to present it on your page.
- 52:08And it's all little simple bits, but combining it all together is...
- 52:13I remember when I first learnt this was a bit complex.
- 52:16So, I wanted to demonstrate that in a few days.
- 52:19And probably the fun part here was choosing some interesting APIs to play with.
- 52:25And the first one I chose was the Pokemon API.
- 52:29Actually, no.
- 52:29The first one I chose was Chuck Norris.
- 52:31So, there were two, Pokemon and Chuck Norris.
- 52:33And 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:42And that color then shoots off to the Pokemon API and returns...
- 52:47You get returned a list of all Pokemon with that color.
- 52:51And then, you know, the course shows you how to list that data on your page or print it onto your page.
- 52:57So, really simple stuff, but really actionable.
- 53:01And you get that instant feedback of, hey, look what I just made.
- 53:04This is cool.
- 53:05And because you get to see the Pokemon API, you get to see all the cool little things that you can pull.
- 53:11So, 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:19And it was just really cool to see.
- 53:22But what was actually quite hilarious was the Chuck Norris API.
- 53:25So, I couldn't believe it existed first and foremost, which just killed me for a day.
- 53:31But the API just returns a Chuck Norris joke.
- 53:35And the reason this is so funny is because obviously the jokes are hilarious and lame and terrible, whatever.
- 53:41But I didn't realize they were some could kind of be inappropriate.
- 53:47And I didn't realize until after I'd recorded everything and put all this time into the course.
- 53:55And then I got to the end.
- 53:56I'm like, oh, that joke wasn't fantastic.
- 53:58So, I think there's a disclaimer in the course now saying, look, just please ignore any jokes.
- 54:02Just this is more for the API, not so much for the joke.
- 54:05Yeah, it's funny though.
- 54:06This was a great chapter to do.
- 54:08It's really actionable and a lot of fun.
- 54:09Yeah, and consuming APIs, especially from Python where we have requests and other things like that, AIoHCP client, for example.
- 54:16It's so accessible.
- 54:18I think before people try it, if they haven't, it sounds like, oh, this integration might be hard.
- 54:23Like, usually it's not.
- 54:25Yeah, it's actually quite simple.
- 54:27And 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:34And doing the very simplistic Flask forms that are built in are nice.
- 54:39And then it's a nice gateway into the WT forms that Flask has as well.
- 54:45Yeah, it's good.
- 54:46A lot of good stuff in that one.
- 54:47Yeah, great.
- 54:47I want to wrap it up with some JavaScript stuff, actually.
- 54:52One of the things that I'm not really a super fan of JavaScript, although I use plenty of it here and there.
- 54:59You 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:07And then, like, maybe there's some API endpoints.
- 55:09And I always find apps like that are, I don't know.
- 55:14They're okay, but they always seem to, like, break down or have these little glitches or just, like, weirdnesses about them.
- 55:19So 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:27But 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:39As opposed to, say, Angular, which is, you know, it's got a lot of structure.
- 55:43It requires TypeScript and things like that.
- 55:46Bob, you talked about React.
- 55:47And actually, React is really cool.
- 55:49There's some great examples.
- 55:50There's this one of building a whole bunch of different apps, and one of them is this, like, recreation of the Mac calculator.
- 55:57And it looks really, really good.
- 55:58I'll link to that as well.
- 55:59So React has got some cool examples and options.
- 56:02But I just found Vue.js to be so clean and simple.
- 56:06You just create a little Vue.js app in JavaScript.
- 56:08You give it values like name, colon, right, nothing or string or whatever.
- 56:15And it does two-way data binding.
- 56:17It's got a lot of plug-ins for editing it.
- 56:19So if you're building these front-end apps, I definitely recommend people check out Vue.js.
- 56:24It's just, it's got, like, a real minimal, easy-to-get-started type of front-end framework there.
- 56:29So another thing that I thought was interesting was Axios.
- 56:33And, Bob, you and I talked about Axios as well, right?
- 56:36Like, Vue.js doesn't have a native way to talk to web services.
- 56:39But Axios, this is a JavaScript plugin library.
- 56:43I will link to that as well.
- 56:44It's a super simple way to talk to APIs from your JavaScript.
- 56:50And it's just, I don't know, I love it.
- 56:51I'm like, wow, this actually makes this so incredibly easy.
- 56:54It's a super useful library.
- 56:56I 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:06And, yeah, it made it so easy to retrieve data.
- 57:10It's really, if you're working with JavaScript and APIs, you should check out Axios.
- 57:15And then I want to throw in two other quick things.
- 57:17There's something called the Quasar framework, which builds on top of Vue.js.
- 57:22And it has a whole, just a ton of these, like, widgets and controls that you can just, in Vue.js, just include.
- 57:31And 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:39And then the other thing is something called Vue.py, Vue.py.
- 57:45And 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:56Wow, cool.
- 57:57That's really cool.
- 57:58Yeah, it's really cool.
- 57:59So I think it uses Brython.
- 58:01Let me look real quick, but I'm pretty sure.
- 58:03Yeah, so you can define, like, a Vue component, for example, by just deriving from the Vue component.
- 58:09So, like, from Vue, import Vue component, class, hello Vue.py, parenthesis, Vue component.
- 58:15And it's really quite interesting there.
- 58:17So I'm not sure that it's a good idea, but it's a very interesting idea.
- 58:22Maybe it's a good idea.
- 58:23It depends what you're building, right?
- 58:24Like, 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:34The JavaScript, you've got to download to get that to work.
- 58:36But, yeah, it's Brython.
- 58:37So 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:47So Vue.py is pretty interesting.
- 58:48That was Dias 93 to 96, and people can check that out.
- 58:52There's an example of consuming a movie service API using Axios and Vue.js.
- 58:58Well, you guys, that's pretty much it from our course and the topics we're going to cover.
- 59:02Mostly that's it for time because we've covered a lot, right?
- 59:04Oh, yeah.
- 59:05A lot of technology there.
- 59:06That's, like, six months worth of content.
- 59:08Yeah, I would say.
- 59:09And, you know, this is only 12 topics.
- 59:11So we covered maybe 13 or 14.
- 59:12A few got kind of doubled up.
- 59:14In the course, we actually covered 28 different technology topics in these different segments, which is pretty insane.
- 59:21So let me just ask you about this.
- 59:23What 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:33Okay, so for me, I would say it's just that there's so much out there.
- 59:39If 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:52So my takeaway is, okay, yes, there's all sorts of JavaScript frameworks out there.
- 59:57Yes, there's all sorts of web frameworks for Python.
- 1:00:00Choose one.
- 1:00:01Learn 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.
- 1:00:10And then once you've got your thing going, then potentially look at something else that might iterate over that.
- 1:00:16But, yeah, I just couldn't believe, as I was doing a lot of the research, I couldn't believe how much is out there.
- 1:00:22And 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.
- 1:00:31And vice versa.
- 1:00:32Yeah, stuff that wasn't there when we finished.
- 1:00:36Exactly.
- 1:00:37There was, what's that library that Kenneth Reitz makes the, not request the other one that he just came up with?
- 1:00:44Responder?
- 1:00:45Responder.
- 1:00:45Like that came out while we were making this course, I'm pretty sure.
- 1:00:48So that sort of thing is just going to keep happening.
- 1:00:51So this is why I'm flask and Bob's Django.
- 1:00:54Bob, what are your thoughts on this?
- 1:00:57My takeaway is similar.
- 1:00:58There's so much going on that it's easy to get scared and it's daunting.
- 1:01:03But I think it comes down to grasping the fundamentals.
- 1:01:07So for me, that really is some HTML, CSS and JavaScript.
- 1:01:13You absolutely want to know at least the basics of those.
- 1:01:16And for Python, yeah, look into a framework.
- 1:01:19There are people with more preference for flask, do it yourself or Django, the whole suite in one.
- 1:01:26I'm more the latter.
- 1:01:28And then I guess go deep in the framework of your choice.
- 1:01:32And another, yeah, fundamental.
- 1:01:34You always want to know some database skills, even some raw SQL I would recommend.
- 1:01:40And yeah, so the fundamentals and then choose the tools of your preference and go deep.
- 1:01:46Yeah, that's good advice.
- 1:01:46And definitely, Julian, you're right that you can just spend your time constantly chasing
- 1:01:51like the next new thing.
- 1:01:53And they come and go so fast that like you will never actually get to somewhere to be
- 1:01:57like doing something concrete and building it on if you just keep doing that.
- 1:02:01Just pick one of these things, start learning, right?
- 1:02:05Like you can always transition later for the next project if you decided you like something
- 1:02:08better in the end.
- 1:02:09But you just got to like put a stake in the ground and start somewhere.
- 1:02:12The other one I'd like to point out is you don't have to learn JavaScript to build decent
- 1:02:18web applications, right?
- 1:02:19Or if you do, it's an extremely small amount.
- 1:02:21Like if you listen to people talk on the web, it's like, oh, you got to know like Angular,
- 1:02:26you got to know this, you got to know that.
- 1:02:27And it's like you can, but you absolutely can build awesome stuff with Django, Flask, Pyramid,
- 1:02:32whatever, just using server side stuff and maybe like a smidgen of interactive, you know,
- 1:02:37focus this text box or maybe show this dialogue.
- 1:02:41But that's about it, right?
- 1:02:42You can learn just Python or you can learn just JavaScript, but like you don't have to
- 1:02:46like necessarily learn them in parallel.
- 1:02:48Yeah, I think that's a great point, especially when people in the community ask like, I want
- 1:02:53to make a blog and I need to learn Django.
- 1:02:55That's fine, but you can actually use static sites and GitHub, right?
- 1:02:59And so you don't actually have to learn Django per se.
- 1:03:02So I would definitely really look at what you're building and then try to choose the right
- 1:03:07tool because it's easy to overdo it.
- 1:03:10All right.
- 1:03:10Maybe it's Netlify and Pelican or something.
- 1:03:11Yeah.
- 1:03:12Yeah, exactly.
- 1:03:13Yeah, exactly.
- 1:03:13Yeah.
- 1:03:14Cool.
- 1:03:14All right.
- 1:03:15Well, that was a lot of fun to talk about those.
- 1:03:17Let me ask you both the two questions before we get out of here, though.
- 1:03:20If you're going to write some Python code, Bob, what editor do you use?
- 1:03:24VS Code?
- 1:03:25Vim.
- 1:03:25Vim?
- 1:03:27It's still Vim.
- 1:03:28Yeah.
- 1:03:29It's just habits.
- 1:03:30Yeah.
- 1:03:30Yeah.
- 1:03:31Cool.
- 1:03:31Julian?
- 1:03:32Well, I was going to say Vim because that's just what I use.
- 1:03:36But look, if I got to choose some other one, I'd actually stick with Notepad++.
- 1:03:40I actually really enjoyed that.
- 1:03:42Yeah, that's cool.
- 1:03:43And I guess I'll throw mine in there as well.
- 1:03:45PyCharm.
- 1:03:46That's not a huge surprise to people.
- 1:03:47Now, notable PyPI package.
- 1:03:49I 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.
- 1:04:00So, there's got to be some that you're like, I didn't even know about this.
- 1:04:03And it's really cool.
- 1:04:04Bob, you want to go first?
- 1:04:06I guess the question for this episode is notable PyPI packages that's not mentioned before.
- 1:04:12So, I cannot go on with Django.
- 1:04:14Yeah, it could be one that you mentioned before.
- 1:04:16Yeah, but Django would be a bit not a surprise.
- 1:04:20Now, for example, for web scraping, right?
- 1:04:23Two weeks ago, we had a live code challenge and we were scraping some PyCon Spain website data and beautiful soup, right?
- 1:04:31It's a great package that makes it easy to traverse the DOM.
- 1:04:36And yeah, I'm still happy with that package.
- 1:04:38It's very easy to use and gets the job done.
- 1:04:41Yeah, and if you want to keep it short, you could pip install BS4.
- 1:04:44Yeah, even shorter.
- 1:04:45Exactly.
- 1:04:47Julian?
- 1:04:47It's actually got nothing to do with web stuff because Flask would be a no-brainer for me here.
- 1:04:52But one of the ones that I've used time and time again, especially at work, has actually been PXpect.
- 1:04:58You guys heard of that?
- 1:04:59I haven't heard of that, no.
- 1:05:00It's a little automation library or module.
- 1:05:03It's pretty much the main function is to automate interactive processes that provide predictable output.
- 1:05:11So, think Telnet, SSH, Git and everything like that.
- 1:05:14So, you can automate what's going to happen because you know what your response is going
- 1:05:18to be when you SSH to a server.
- 1:05:20You know that the password prompt is going to come up.
- 1:05:23So, you can code in.
- 1:05:24Okay, when you get this exact prompt, now what do you do?
- 1:05:28And it's really cool.
- 1:05:30There's a whole, obviously, bunch of documentation on it.
- 1:05:32But that's a library module I really like.
- 1:05:35Yeah, that's really cool.
- 1:05:36It does SSH, FTP, Telnet, all sorts of cool stuff.
- 1:05:40I love it.
- 1:05:41See, this is why I asked this question because I learned something every time.
- 1:05:45The one I'm going to throw out there is unsync.
- 1:05:48So, I talked about unsync before.
- 1:05:51It basically unifies all the different ways of doing asynchronous programming in Python and puts the async and await interface on it.
- 1:05:59And it's beautiful because it's only 126 lines in a single Python file.
- 1:06:05And yet, it basically fixes most of Python's async API.
- 1:06:10It's unbelievable that happens in such a small amount of effort.
- 1:06:13So, really love that one.
- 1:06:15And if you're doing async programming, check that out.
- 1:06:17Yep.
- 1:06:17All right, guys.
- 1:06:18Thank you for being here.
- 1:06:19Julie and Bob.
- 1:06:21Thank you.
- 1:06:21It's good to be back, Mike.
- 1:06:22Thank you for having us again, man.
- 1:06:23Yeah, yeah.
- 1:06:24Thanks for writing this course with me.
- 1:06:25We all learned a lot.
- 1:06:27And it was fun to share with everyone a little bit.
- 1:06:28Cheers, man.
- 1:06:29We'll see you next time.
- 1:06:30Cheers.
- 1:06:30Yep.
- 1:06:30Bye.
- 1:06:30This has been another episode of Talk Python To Me.
- 1:06:34Our guests on this episode were Bob Bilderbos and Julian Sequira.
- 1:06:38And it's been brought to you by Ting and Linode.
- 1:06:40Ting is the fast mobile network custom built for technical folks.
- 1:06:44Use their savings calculator to see exactly what you'd pay.
- 1:06:48Visit python.ting.com to get a $25 credit and get started without a contract.
- 1:06:54Linode is your go-to hosting for whatever you're building with Python.
- 1:06:57Get four months free at talkpython.fm/Linode.
- 1:07:01That's L-I-N-O-D-E.
- 1:07:03Want to level up your Python?
- 1:07:05If you're just getting started, try my Python Jumpstart by Building 10 Apps course.
- 1:07:10Or if you're looking for something more advanced, check out our new async course that digs into
- 1:07:15all the different types of async programming you can do in Python.
- 1:07:18And of course, if you're interested in more than one of these, be sure to check out our
- 1:07:22Everything Bundle.
- 1:07:23It's like a subscription that never expires.
- 1:07:25Be sure to subscribe to the show.
- 1:07:27Open your favorite podcatcher and search for Python.
- 1:07:29We should be right at the top.
- 1:07:31You can also find the iTunes feed at /itunes, the Google Play feed at /play, and the
- 1:07:36direct RSS feed at /rss on talkpython.fm.
- 1:07:40This is your host, Michael Kennedy.
- 1:07:42Thanks so much for listening.
- 1:07:43I really appreciate it.
- 1:07:44Now get out there and write some Python code.
- 1:07:46I'll see you next time.
- 1:08:07Thank you.