Latest / Talk Python To Me / #177: Flask goes 1.0
Transcript
- 0:00Flask is now eight years old, and until recently had been going along pretty steady state.
- 0:04It had been hanging around at version 0.11 and 0.12 for some time.
- 0:09After a year-long effort, the web framework has now been updated to Flask 1.0.
- 0:14David Lord is here to share the big news with us.
- 0:17He's the maintainer of Flask, and we dive into the new features,
- 0:20as well as the future directions of Flask with him.
- 0:22This is Talk Python To Me, episode 177, recorded August 30th, 2018.
- 0:28Welcome to Talk Python To Me, a weekly podcast on Python,
- 0:45the language, the libraries, the ecosystem, and the personalities.
- 0:48This is your host, Michael Kennedy. Follow me on Twitter, where I'm @mkennedy.
- 0:52Keep up with the show and listen to past episodes at talkpython.fm,
- 0:56and follow the show on Twitter via at Talk Python.
- 0:59This episode is brought to you by Linode and 10x Agent On Demand.
- 1:04Please check out what they're offering during their segments. It really helps support the show.
- 1:07David, welcome to Talk Python.
- 1:09Hello. Thanks for having me.
- 1:11Hello. Yeah, it's great to have you here.
- 1:13It's really good to see lots of vibrant activity around Flask,
- 1:17and I know you're at the heart of much of this activity,
- 1:20and I'm super excited about diving into it with you.
- 1:23Yeah, let's get started.
- 1:24Yeah, for sure. And so we're going to dive into Flask and the news that Flask 1.0 is now out.
- 1:29That's a big deal, but let's get started with just your background.
- 1:32How do you get into programming in Python?
- 1:33Let's see. So I've been programming most of my life.
- 1:36I got into it probably around like second grade or so.
- 1:39Got a book about HTML, started making websites.
- 1:42Nice.
- 1:42Where I really like started and what I thought I wanted to do,
- 1:44and I think this is the story for a lot of people,
- 1:46is I thought I wanted to make video games when I grew up,
- 1:49because I started with a game maker when I was in like middle school and everything,
- 1:54making like 2D games.
- 1:56I wish I had saved now, but I didn't know about Git back then,
- 2:00so I didn't know about this back then maybe.
- 2:02So they faded into the digital dust?
- 2:05Yeah, unfortunately.
- 2:06So yeah, I got started that way and then went to college for computer science
- 2:11and eventually just kind of settled on like, oh, web apps are pretty cool.
- 2:15Like I started making like some small things for groups I was involved with,
- 2:19and eventually that's how I got into Python also.
- 2:23There was like a Python course in college, but even before that,
- 2:26I started thinking like, hmm, what can I do next?
- 2:29Because I'm just doing Java here and it's not that exciting.
- 2:32So I went one summer and I was looking at how to make a web application
- 2:36and I came across Ruby on Rails and Django.
- 2:38So I looked at both of them.
- 2:40Two very different directions that could have gone great.
- 2:43Yes.
- 2:44I looked at both of them.
- 2:45Looking at the growth curves and popularity curves of these two languages,
- 2:49you know, 10 years out or whatever,
- 2:50you probably got a good choice on the fork in the road there.
- 2:54Yeah.
- 2:55I mean, I'm sure there's plenty of good stuff you can do with Ruby also,
- 2:58but back when I was starting, I looked at both of them,
- 3:01looked at the code and said, not knowing Python or Ruby,
- 3:04hey, I can read this Python.
- 3:05It makes sense.
- 3:06And so I just started using that.
- 3:09Picked up the Django tutorial back when I think it was like 0.8 or so.
- 3:13And I think Flask may have just come out or was going to come out the next year.
- 3:18So it was like 2008, 2009 around that.
- 3:22And so that's how I got started.
- 3:23It just kind of went from there.
- 3:24Yeah, that's awesome.
- 3:26So I guess one of the interesting follow-up things is like,
- 3:29how do you go from Django to Flask?
- 3:31Like I just interviewed some folks for the Python survey done with the PSF
- 3:37and JetBrains collaboratively.
- 3:38And the number one framework,
- 3:40the most popular framework that anybody picks up for anything in Python is Django.
- 3:46And so it's certainly really popular.
- 3:48So you've strayed.
- 3:50You've strayed from Django.
- 3:51How did you get over to Flask?
- 3:52It's funny.
- 3:53I want to touch on those most popular things also.
- 3:56I don't want to start a fight with Django or anything.
- 3:57But we'll go into how I did Flask first.
- 4:00So for my job after college, I got put on a contract where it was basically open-ended.
- 4:06Like they wanted this.
- 4:07I mean, this is literally the line I got the first day I walked into the client's office was,
- 4:12we have this spreadsheet.
- 4:13Can we put it online?
- 4:15Like an Excel spreadsheet.
- 4:18And so the company I was working at, and I still work for them,
- 4:22they were a Java shop.
- 4:23And that's what my previous projects had been in.
- 4:27But I was the only person on this contract over at the client's office.
- 4:31I said, yeah, we can put that spreadsheet online in Django,
- 4:34which I've been learning, which I was learning before I started here.
- 4:37And I did it before anybody could say anything, you know.
- 4:41You know, the best way to quiet dissenting voices in those situations
- 4:47is to show them something working.
- 4:49They're like, oh, you should use Java.
- 4:51Wait, that works.
- 4:52You're already done.
- 4:53Okay.
- 4:54Well, I guess, all right, fine.
- 4:55You can do that, right?
- 4:57Did it go something like this?
- 4:58By the time they checked in a couple weeks later,
- 5:00we already had like a working prototype.
- 5:02And, you know, we've gone beyond the spreadsheet at that point.
- 5:05Yeah.
- 5:05Have they been using like the spreadsheet as like almost a web app database?
- 5:10Were they like mailing it around?
- 5:12What was the story?
- 5:13I don't know how many details I want to give like publicly.
- 5:17Yeah, yeah, sure.
- 5:18It was basically they were keeping track of how secure their computers were for various audits that they needed to do.
- 5:25And everybody was just basically reporting about their computers and somebody was filling out a spreadsheet.
- 5:30And then they would go and look at the statistics every now and then.
- 5:34So they wanted some way to people can like report that automatically.
- 5:37They can get the reports about compliance automatically.
- 5:42So it's kind of like just a data collection and reporting.
- 5:46Yeah, I just I asked because it seems like there's just so many sort of holes like that that Excel fills.
- 5:52That was just a little bit of skill.
- 5:54You know, like a much better solution would be in place.
- 5:56Yeah.
- 5:57Well, the contract ended up lasting like three years and far outgrew what Excel would ever have done.
- 6:03But it started from pretty humble beginnings.
- 6:05Nice.
- 6:06Okay, so that's Django.
- 6:08So how'd you get to Flask?
- 6:09Right, right.
- 6:09So we were on Django.
- 6:10And so we made this prototype and it was working well.
- 6:13And they're like, well, we want to start using this every, you know, for the company now.
- 6:17And so we deployed it and it ended up being too slow.
- 6:22Now, I'm not saying Django is too slow.
- 6:24That's probably partially on me.
- 6:26Like I was still learning and everything.
- 6:28But at the time, you know, it was a SQLite database.
- 6:32The templates were kind of slowing down in rendering.
- 6:36And the biggest problem was the ORM at the time.
- 6:39And I know you can do clever things even in the Django ORM.
- 6:42But I like was trying to do all these reports and aggregates and everything.
- 6:46And it was kind of finding Django.
- 6:48So I started looking for something, you know, alternatives.
- 6:52I found SQLAlchemy.
- 6:53And I found Flask, which SQLAlchemy was used with a lot.
- 6:56So I said, okay, I'm just going to rewrite the whole thing in Flask and see what happens.
- 7:01And that's about how it happened.
- 7:02I just had a Django site and I needed more performance and more customizability.
- 7:08And so I switched to Flask.
- 7:09Yeah.
- 7:10And was it pretty easy?
- 7:11Was it like a couple days?
- 7:13This is like six years ago now.
- 7:15But yeah, it was pretty straightforward.
- 7:18And like I said, like, I think I probably could have accomplished the same thing in Django eventually.
- 7:23I knew a lot less at the time also.
- 7:24And so I was more just exploring what was out there.
- 7:26But it was definitely, we built something on it for three years after that.
- 7:30Yeah.
- 7:30So it was a really good foundation in the end, huh?
- 7:32Yeah.
- 7:33I'm a fan of the micro framework style.
- 7:35You know, take a small web framework, pick the ORM and other tools that you want to use for that situation and put them together.
- 7:43I don't know.
- 7:44That's my style.
- 7:44So I'm a fan of that style as well.
- 7:46Yeah.
- 7:47I'm not biased or anything, but I'm definitely a fan of that also.
- 7:50For sure.
- 7:52Yeah.
- 7:53So we're going to talk a lot about Flask, but let's start at a more higher level umbrella style angle here.
- 8:01So when I went to look about Flask, it's now under this Palette Project umbrella.
- 8:08And a couple of years ago, I don't think it was.
- 8:11So what is Palette and how did Flask get there?
- 8:15So Palette is, it's like basically the new organization that's managing Flask and the other projects related to Flask.
- 8:23So VerkZoik, Jinja, Click, MarkupSafe, It's Dangerous.
- 8:28And there was a previous organization called Poku, which your listeners are probably familiar with,
- 8:35because when you go to the Flask documentation, you're still going to flask.poku.org.
- 8:40Right.
- 8:41That was Armin Roeneker's stuff, right?
- 8:44It was him and some of his friends.
- 8:46They had started various projects and Flask came out of that.
- 8:50Spinks came out of that.
- 8:51Other projects came out of it that I'm remembering off the top of my head.
- 8:54But everybody just kind of ended up moving on eventually.
- 8:58And so it had become just Armin managing all these projects himself.
- 9:03And he wanted to open it up more to the community.
- 9:06And so he created this new Palettes website and said, okay, everything belongs to this organization now.
- 9:12And I'm going to try to get more community involved.
- 9:15And so that's how I kind of, that's about the same time that I got into the project as well.
- 9:20And honestly, we haven't really picked up a lot more maintainers since then or anything.
- 9:25It's still just a couple of maintainers going at things.
- 9:28But it was like more of a significant like, it's not Armin's project anymore.
- 9:33Right.
- 9:33I was going to say, it kind of got Flask out of the shadow of Armin.
- 9:37Right.
- 9:38And he's still there.
- 9:40Like I chat with him about like, hey, do we want to do things like this?
- 9:43Or he still manages a lot of the assets behind the scenes like servers and that sort of thing.
- 9:47But day to day, it's me and the contributors that I kind of have gotten on board.
- 9:52All right.
- 9:53Right.
- 9:54Are you looking for more contributors?
- 9:55Absolutely.
- 9:56I don't know if you want to go in depth on that now.
- 10:00Yeah, sure.
- 10:02Let's talk about it just a little bit.
- 10:03Because I know a lot of listeners will reach out to me and say, hey, I'm getting into open source.
- 10:08I'm getting into this whole Python world.
- 10:10And I would like to contribute to something.
- 10:12But I feel like they contemplate creating something for themselves.
- 10:17And like, well, I could build this thing, but I don't really have a great use case for it.
- 10:20Or I'm not sure it'll be popular.
- 10:21And then they look at contributing to other projects.
- 10:24We talked about Django.
- 10:25Django is really like a big polished project that is super hard and approachable for people to get into.
- 10:33And so they're like, well, I can't get into these major projects because they're too advanced or too, you know, widely used.
- 10:39Whereas the small, simple stuff, I don't think it's going to make a lot of sense.
- 10:42So they ask you, well, what projects could I get involved with?
- 10:45And like, where can I help out?
- 10:46So if there's like a good place for people getting started or people who love Flask and want to get more involved, that'd be great.
- 10:52Yeah.
- 10:52So we're definitely looking for more contributors in all of the projects that I mentioned earlier.
- 10:57So Flask, Berkswake, Jinja, everything out there.
- 11:01The biggest success I have at finding contributors is at PyCon.
- 11:05And I'll run the sprints and I'll find people who are interested.
- 11:08You know, they'll come to me basically.
- 11:10And I get to walk through everything in person, which is really helpful.
- 11:13But I am trying to, I do get contacted occasionally, like saying, hey, can I contribute to Flask?
- 11:19And I'm like, absolutely.
- 11:20Do you want to write documentation?
- 11:21Do you want to write tests?
- 11:22Do you want to make sure our configurations are consistent across all six projects?
- 11:29Do you want to triage issues and see, can you reproduce things?
- 11:33Can you get more information out of people?
- 11:35Can you identify where a problem is?
- 11:37Right.
- 11:38Triage all the issues that come rolling in, right?
- 11:40Right.
- 11:41So like, even if you're not comfortable, like writing code yet, and you should be, you absolutely
- 11:46can contribute code to any of our projects.
- 11:48But there's plenty of non-code related contributions out there that are really helpful to me.
- 11:53So they give me more time to focus on the code.
- 11:55Yeah, that's awesome.
- 11:56Do you feel like it's a little easier to contribute to Flask because it's like six projects?
- 12:02And each project is a little easier to hold conceptually in your mind?
- 12:05It might be.
- 12:06I mean, there are really, there's four main projects.
- 12:09Flask, VarxSoy, Jinja, and Click are all pretty large code bases in themselves.
- 12:14And they're pretty distinct use cases.
- 12:16So there's not too much to do actually in Flask specifically anymore.
- 12:211.0 kind of said like, acknowledge, you know, here we're stable and we have the features we want
- 12:28at this point.
- 12:30So like, in terms of like bug fixes, like there's some bug fixes every now and then,
- 12:34but a lot of the work is in VarxSoy and Click especially.
- 12:38There's a lot of stuff behind the scenes that people don't see when they use Flask every day,
- 12:41but it affects them.
- 12:42I think a lot fewer people are aware of those also.
- 12:45So like, people just being aware of those projects and looking at them also and not just Flask would
- 12:49be really helpful.
- 12:50And there's always tutorials and documentation that could use upkeep, right?
- 12:55Like I went through and just for Flask 1.0, rewrote the entire Flask tutorial from scratch,
- 13:01just kind of based on the questions and stuff I had experienced answering questions on Stack
- 13:07Overflow, answering, helping people at meetups or conferences.
- 13:13And so identifying those kinds of things like, hey, this didn't work for me in the docs, you know, or this could have been clearer and going and contributing there.
- 13:20Yeah, that's cool.
- 13:21I often think of like, every time there's a question about something that I thought was explained well,
- 13:26but then it turns out there's a question about it.
- 13:28You're kind of like, ah, it's almost like an issue on that explanation, right?
- 13:32Most of the issues in Flask right now, the open issues on the bug tracker are documentation, really.
- 13:37Like people have brought up, like, this is confusing or this could be clearer.
- 13:41And if you're looking for even more issues, just go on Stack Overflow, go to the Flask tag and sort by most voted questions.
- 13:48And just look at the top one, see if it's documented.
- 13:52Look at the next one.
- 13:53Yeah, that's a really good point, actually.
- 13:56So it occurs to me that it might be worthwhile to spend just a moment talking about these projects that you discussed.
- 14:02So we just quickly ran through it, like there's Flask and there's Jinja and there's Werkzeug and stuff like that.
- 14:07And could you maybe give us a rundown of like what each one of those actually is so people know what they're about?
- 14:12Sure.
- 14:13So, yeah, Flask is definitely the most popular.
- 14:16But if you're using Flask, you're using the five other libraries also behind the scenes.
- 14:21Like, so every time you pip install Flask, you get all these also.
- 14:23And Flask, honestly, is just a wrapper around all these other libraries.
- 14:28It's using what's provided there and just putting a nice framework around it.
- 14:32So Werkzeug is the closest to what Flask is doing.
- 14:36It's also a WSGI library, but it's dealing with kind of a lower level than what Flask is.
- 14:42So Flask is providing like an application framework and Werkzeug is providing all the parts for taking a HTTP request and a WSGI request and parsing out the headers and producing some data structure,
- 14:57like a request that we can use and look at and turning our response into something that our server can understand.
- 15:04Jinja is a templating library, which means you write text files with special syntax in it that kind of looks like Python.
- 15:13It actually compiles to Python behind the scenes.
- 15:16And then you can render these templates and produce different web pages, for example, different HTML pages with user information or different details about different objects.
- 15:27Click is the most recent Palettes project, but it's four years old at this point.
- 15:33So it's not that recent, I guess.
- 15:35It's probably also the one used most independently.
- 15:38Yeah, that's true.
- 15:40I wish I could name more projects off the top of my head that used it, but I do know PIPend uses it, Cookie Cutter uses it, and Flask uses it, obviously.
- 15:48And that's our command line tool.
- 15:51So it's kind of like Flask in a sense, but for command line applications instead.
- 15:57So you use decorators to turn functions into commands that you can run with options and arguments and produce terminal output.
- 16:08Right. Nice.
- 16:08And there's all sorts of...
- 16:10Click is kind of unique.
- 16:11It tries to be very correct about how it interacts with the environment it's running in, in terms of encodings for the terminal, for the file system, for user input.
- 16:25And it actually, I think, I don't know the full history, but I think in part influenced some recent changes in Python 3.7, where Python now handles UTF-8 encodings better, detecting those on Linux machines.
- 16:38Because Click would actually complain, like, your system is not configured right, and I'm not going to try to get...
- 16:43Right.
- 16:44Right.
- 16:44Which led to a lot of headaches for people writing tools.
- 16:47But it did make people...
- 16:48Yeah.
- 16:48...better.
- 16:49Yeah, yeah.
- 16:50So one thing I want to highlight, and I'm not sure if people are aware of this, that GitHub recently added dependency computations or dependency reports for Python.
- 17:00That used to be just for Ruby and JavaScript.
- 17:02But if you go to, like, palette slash Click on GitHub and go to Insights, then Dependency Graph, and then Dependents, you can see there are 82,408 repositories and 4,774 packages that depend on Click.
- 17:15And there's the list of them.
- 17:16Okay.
- 17:17Wow.
- 17:17I haven't actually...
- 17:20I remember vaguely seeing that they had released that, and I haven't looked at it yet.
- 17:24That's really surprising.
- 17:25It's really cool.
- 17:26Dependency Graph.
- 17:28I'm looking at it right now.
- 17:29Oh, yeah.
- 17:29Yeah.
- 17:30It's good to draw you in, right?
- 17:31And you can also see the dependencies, like, in reverse.
- 17:33So it's good for, like, saying, what does this project depend upon if you're going to try to decide if you want to use it, right?
- 17:40But I think the other one is interesting for people like you who create these packages and then other people depend upon them.
- 17:47And you'll see, like, well, what else is out there?
- 17:49Yeah, it's really cool.
- 17:50It's just, like, an absolute number.
- 17:52The other package I use for getting statistics like that is PyPInfo.
- 17:56I don't know if anybody's discussed that on your podcast before.
- 17:59No, I don't think we talked about it.
- 18:01Yeah, you have, they have all the statistics about PyPI downloads, and you can just query that through Google BigQuery.
- 18:08That's why I was questioning your, Django's the most popular earlier, because if you go look at it month to month, it's not like I monitor this every month or anything.
- 18:18But Flask and Django are neck and neck.
- 18:22Really?
- 18:23And some months, Flask will be higher by a couple tens of thousands, even, and sometimes Django will be higher.
- 18:29It's really surprising, though, because despite them being downloaded the same amount, if you look at statistics like number of questions asked on Stack Overflow, Django has, like, probably, I think, like 50,000 times more questions.
- 18:43It's like a ridiculous number.
- 18:44Yeah.
- 18:44Well, I wonder if that's a micro framework versus sort of, I think of, like, Lego building block frameworks like Django.
- 18:50Like, you wouldn't ask so much, you wouldn't say tie a question about SQLAlchemy to Flask because it's about SQLAlchemy.
- 18:56But you very much, it's very common that you might do that for, say, Django ORM being tied to Django, even though it's the data, because it's more like grouped together.
- 19:05I don't know.
- 19:06Yeah, I'm not sure if you can even read anything into that.
- 19:09Like, it's maybe there's just a bigger community, and so there's bigger awareness of Django that people think to ask questions about in the first place.
- 19:17Yeah, but I think maybe the main takeaway is Flask and Django are both well up there as some of the most popular frameworks for Python.
- 19:23Sure.
- 19:24Okay, so let's see.
- 19:25We talked about Flask, Jinja, Vixoy, Vixoy.
- 19:28Yeah, thank you.
- 19:29And we just touched on Click.
- 19:30So we got MarkupSafe and It's Dangerous.
- 19:33Right.
- 19:34So MarkupSafe is kind of used internally by Jinja, and it is just a very fast implementation of escaping unsafe characters in HTML.
- 19:45So basically...
- 19:46Like, if you're going to take something from a database and plunk it into the web page as a string, you're going to HTML encode that before you do that so it doesn't get owned.
- 19:54Right, right.
- 19:55So if you have user input or anything like that, you're going to make sure it's safe to display to people without them being able to inject unsafe code into their browser.
- 20:04And so it's just a very fast implementation of that.
- 20:07And plenty of other projects use it behind the scenes.
- 20:10Okay, that's interesting.
- 20:11But I think Django might even use it.
- 20:15Yeah, you can go to the Insights on GitHub now.
- 20:17Or just their requirements at DXT.
- 20:20But yeah, and then we have It's Dangerous as well, right?
- 20:24Yeah, so It's Dangerous is the last one.
- 20:26And that's just a way to securely sign messages.
- 20:30And I know there's other solutions out there now, like JWT, that sort of thing.
- 20:34But those didn't really exist at the time this was written.
- 20:37And this is a lot simpler than JWT.
- 20:39So basically, it's kind of like JSON.dumpS.
- 20:42Yeah.
- 20:43Just throw out some data, and it will dump it into a JSON string.
- 20:46Then it will also securely sign that string so that you know that it can't be tampered with.
- 20:51Right, tamper-proof marker.
- 20:53But they can't edit it.
- 20:54So we use it for our secure cookies and for signing things like login tokens and preset tokens.
- 21:01Yeah.
- 21:02Yeah, you don't want people tampering with that stuff.
- 21:06This portion of Talk Python To Me is brought to you by Linode.
- 21:09Are you looking for bulletproof hosting that's fast, simple, and incredibly affordable?
- 21:12Look past that bookstore and check out Linode at talkpython.fm/Linode.
- 21:17That's L-I-N-O-D-E.
- 21:19Plans start at just $5 a month for a dedicated server with a gig of RAM.
- 21:24They have 10 data centers across the globe.
- 21:26So no matter where you are, there's a data center near you.
- 21:29Whether you want to run your Python web app, host a private Git server, or file server, you'll get native SSDs on all the machines, a newly upgraded 200-gigabit network, 24-7 friendly support, even on holidays, and a seven-day money-back guarantee.
- 21:44Do you need a little help with your infrastructure?
- 21:47They even offer professional services to help you get started with architecture, migrations, and more.
- 21:53Get a dedicated server for free for the next four months.
- 21:56Just visit talkpython.fm/Linode.
- 21:59Then there's a few other projects that are not directly under Flask, but are under the palettes or related to palettes, right?
- 22:06Yeah, there's plenty of extensions.
- 22:08There's some that I'm involved with.
- 22:10Flask SQLAlchemy, which is the kind of official extension for tying SQLAlchemy's sessions with Flask sessions.
- 22:17There's Flask WTF, which is a wrapper around WTForms, which is a form library that lets people interact with data submitted from web pages and render those forms that submit that data, do validation, that sort of thing.
- 22:32So the other things I'm involved with, I wrote this library called Flask Alembic, which is kind of like Flask SQLAlchemy.
- 22:38It takes Alembic, which is the migration library for SQLAlchemy and wraps that in kind of the Flask configuration.
- 22:44That's really cool.
- 22:45So I don't believe we've talked about Alembic very much.
- 22:48We've mentioned SQLAlchemy plenty of times, but I feel like Alembic, if you're doing real production relational database stuff with SQLAlchemy, you should know about Alembic to be using it.
- 22:59Maybe give people a quick overview of what Flask Alembic does to that whole mix.
- 23:04Yeah.
- 23:04So I never just use SQLAlchemy unless it's just like a really quick example project.
- 23:09What Alembic does is it does something called migrations.
- 23:12So if you write your model in SQLAlchemy and you create a table in your database, if you want to change that model, the only thing SQLAlchemy lets you do is drop the table completely and then recreate it.
- 23:26Instead, you can run migrations, which lets you add or move columns or change data and just kind of keep version control over what your database looks like.
- 23:37Right. Because with these ORMs, the structure and schema of your database has to at least be a superset of exactly what you have in your SQLAlchemy definition.
- 23:46So if you add like a column or field to your SQLAlchemy class, it can no longer talk to your database without also adapting the database schema.
- 23:54Right.
- 23:54Right. So you need some way to tell the database there is this new column that you need to know about.
- 23:59And that's what Alembic does.
- 24:01So Flask Alembic just kind of ties Alembic, which comes with its own CLI, for example, into Flask's CLI and moves the configuration from Alembic into Flask.
- 24:14Just kind of a...
- 24:16I think so it's kind of like a wrapper.
- 24:18Yeah, it's a wrapper around it.
- 24:20Just like, I mean, mainly like Flask SQLAlchemy is for SQLAlchemy.
- 24:24There's another library out there called Flask Migrate, which is another wrapper around Alembic.
- 24:29And that one's developed by Miguel Grinberg.
- 24:31And we basically, from what I remember, because I developed, it was like four years ago now, but I think we developed them at basically the exact same time.
- 24:41Really, something like a month of each other, completely independently.
- 24:45His is a lot more of a direct wrapper around Alembic, which a lot of people, for a lot of people, is exactly what they need.
- 24:51And it's a lot more straightforward a lot of the time.
- 24:53Mine, on the other hand, I wanted to like be able to dig into all the internals of Alembic and like introspect exactly what was going on at any time.
- 25:01So it's more of a very opinionated framework on my end.
- 25:05And people can choose.
- 25:07Yeah.
- 25:07It's good to have options.
- 25:08That's really cool.
- 25:09Let's spend a little time talking about maybe the biggest news for Flask and that it went from, what was it, like 0.12 to 1.0?
- 25:18Yeah, 0.12.4 to 1.0.
- 25:21Well, here's a major open source project going to 1.0, which is actually, I think, really, really positive.
- 25:29And I think it's, I'm just super excited to see that you guys did that because it's time, I think.
- 25:34Oh, it was absolutely time.
- 25:36I mean, I was, I had been working on that, getting that happening for about a year prior to it, at least.
- 25:41We joked about it, this at PyCon, because Mamuta Shemi had come out with this thing called ZeroVert for ZeroVert.
- 25:46And making fun of projects that were still on like Zero, not something that were 10 years old and Flask was on that list.
- 25:52Yeah, that was actually, I didn't find out about that until after I released 1.0.
- 25:58And then people were like, oh, it was because of ZeroVert.
- 26:01No.
- 26:02I've been doing it.
- 26:03You set the record straight.
- 26:04This is going a lot longer before that.
- 26:05Yeah.
- 26:05ZeroVert.
- 26:06I was very amused by it.
- 26:07I was like, yeah, this is, and I actually got them to put us on the Emeritus list.
- 26:11Aha.
- 26:12Nice.
- 26:13So we're, we're graduated now on their website.
- 26:16But yeah, I've been working on it for a while.
- 26:17And we always have people asking like, hey, this is, this is 0.12.
- 26:22My boss doesn't want me to use it because it's not software.
- 26:26And we kept having to tell people, this has been stable for years.
- 26:32Nothing's really going to change.
- 26:33Nothing's going to change.
- 26:33There's no breaking bugs or anything.
- 26:35It's more just a number.
- 26:37I think for a long time I told them, just tell them it's version 12 and we misplaced to zero or something.
- 26:42Yeah.
- 26:42But yeah, we finally got it.
- 26:44They are.
- 26:44I mean, that is the impression for a lot of people, especially people coming from commercial oriented software backgrounds.
- 26:53I'm thinking like Microsoft shops, you know, .NET folks.
- 26:57I'm thinking Java and those types of people.
- 27:00They're just like, well, I mean, I think they even have a rule of the Microsoft shops.
- 27:03Like you can't use this whole version three because the first two are messed up.
- 27:06Right.
- 27:06And I just think there's so many large organizations that at least some of the folks in there have that mindset.
- 27:13And I think having this become one O is like a pretty big step to just sort of sidestep that conversation.
- 27:19Yeah.
- 27:20And I mean, it feels, it feels significant, even if like the actual stability of the software hasn't changed or, you know, the acceptability to use it in production environments hasn't changed really.
- 27:31But, you know.
- 27:32But there are some major changes.
- 27:34Oh, yeah.
- 27:35I mean, there's, the list is not trivial.
- 27:38Right.
- 27:38I was kind of surprised when I made that release slot or those release notes, just how much it changed.
- 27:46It's a lot of small things, honestly, like, but it adds up.
- 27:50Right.
- 27:50You want to talk us through some of the changes, some of the major changes?
- 27:53So, yeah, we dropped support for Python 2.6 and Python 3.3, which made me really happy.
- 27:59That's really nice.
- 28:01I was looking at, I was trying to use the PyPI info, which I mentioned earlier, to figure out stats about how people were using it.
- 28:06And I think less than 0.1% of installs were on Python 2.6.
- 28:13Yeah, 3.3 itself went unsupported, right?
- 28:16Yeah.
- 28:17It, like, 2.6 itself is unsupported.
- 28:19And in the future, I'm definitely going to be sticking with, as soon as Python drops support for a release, I'm going to drop support for it.
- 28:26Yeah, that makes sense.
- 28:27That doesn't mean we're going to, like, rip out support and, like, it's suddenly going to break.
- 28:31But we're not going to test on it.
- 28:32You know, we're going to...
- 28:33Not going to inject breaking changes to force it to not work.
- 28:36But you're going to no longer run tests and not care if it breaks it.
- 28:39Right.
- 28:40And actually, Flask 1.0 secretly supports Python 2.6.
- 28:44Even though I removed it a couple months before we made the release, I kept testing it internally because I wanted to give people who were deployed at least one chance to be on 1.0 before they had to make a bigger upgrade.
- 28:57Yeah, that was generous.
- 29:00Yeah, I probably shouldn't have done it in retrospective, but it's done.
- 29:03You talked about the versioning going 1.0, like, in the comparison to Django.
- 29:07Django is now in sort of this 1.0.2.0 versioning as well.
- 29:12And they dropped support for Python 2 altogether.
- 29:14Do you have plans for that outside of the deadline of 2020?
- 29:18Yeah.
- 29:19As soon as 2020 comes around, I am dropping support for Python 2.
- 29:23Yeah, and I think that's basically what Django said.
- 29:26It was like their end of life was, it was pretty far out before you could, you're fully unsupported on like an older version of Django or something.
- 29:32Yeah, I'm looking forward to that day.
- 29:34I mean, we'll still be supporting from, I think, 3.4 and up at that point.
- 29:38Sure.
- 29:38So we're still a little behind in terms of features that we're allowed to use.
- 29:42Right, like async and await, for example.
- 29:44Yeah, that's a whole other discussion that we'll get into.
- 29:47Yeah, yeah, for sure.
- 29:49Actually, it is, isn't it?
- 29:50But do you think it will reduce the amount of code that you have to write?
- 29:54Do you think it'll be easier for people to contribute if you don't have to do version checks or compatibility?
- 29:59I haven't really considered it in a while.
- 30:02I think it will cut down on, I think mostly it'll just cut down on mental overhead.
- 30:07Like people don't have to think about it as much.
- 30:09When I write code at this point, I'm so used to doing it for Flask that I just kind of, by default, write code that is compatible with both.
- 30:16And occasionally get a mistake that CI catches.
- 30:19But just having less surface to have to remember and to test, I think will be beneficial.
- 30:24But for the most part, there's, I mean, there's cool features that come out.
- 30:28But clearly all our code can be written in Python 2.7 and compatible code.
- 30:33Yeah, I think what's more important is that people that use Flask get to use the new features where and how they want, you know?
- 30:41Oh, well, people writing applications in Flask can already use Python 3.7 if they want.
- 30:47And they can use f-strings and what was the controversial change that got into 3.7?
- 30:52It's coming in 3.8.
- 30:54It was PEP 572, the like assignment equality thing, the inline assignment.
- 31:01Yeah.
- 31:01Hey, I'm looking forward to when Flask only supports 3.8 and up because I'm going to switch all my code to that also.
- 31:06I personally like the change.
- 31:07Yeah.
- 31:08Yeah, I do as well.
- 31:09Yeah, very nice.
- 31:10Okay, so another major change is the CLI.
- 31:12Tell us about the changes there.
- 31:14Yeah, so I'll talk about the CLI in a second.
- 31:16But basically like all the changes that are, a lot of the significant changes that went into 1.0 are, were basically me trying to make things easier for people.
- 31:27So easier for people to learn, easier for people to understand.
- 31:30So a lot of this stuff is improving documentation, better error messages, and then a better CLI also.
- 31:36So we did a lot of work on improving how the Flask command, which is like the recommended way to run the development server while you're working, how it detects your application.
- 31:48So when you write code, you just write app equals Flask somewhere in your code.
- 31:52And there's even a common pattern called the factory, the application factory, where you write a function that creates your application.
- 31:59So you never actually have an instance of your application where you code.
- 32:02That's what the server is in charge of setting up.
- 32:05And so we did a lot of work to improve how the CLI can detect where your application is, what it's called, how it should be imported, and if it's behind a factory or not.
- 32:16So that the command can just, like everything will just work when you're writing it, instead of having to set up some extra glue in between.
- 32:23Yeah, that's cool.
- 32:25So you no longer have to say set the Flask underscore EMV, no, the Flask debug rather, or the Flask app environment variables, right?
- 32:33It can detect some of that stuff automatically.
- 32:35Yeah.
- 32:36A lot of the times for like really for simple applications, which is really useful for tutorials, especially like Flask app will just know that you have an app, you have a file called app.py.
- 32:46That's where your application is.
- 32:48I'll just look there.
- 32:49You do still have to set Flask app in most significant cases.
- 32:53Like once you're writing a big application, you know, a more significant application, you'll probably have to tell it like at least where the, which files are important, but nothing.
- 33:04This portion of Talk Python To Me is brought to you by 10x Agent On Demand.
- 33:08Here's a guess.
- 33:09If you're listening to my podcast, you're likely a Python pro.
- 33:12You may be even pretty well paid to code in it.
- 33:14Here's another guess.
- 33:15You likely aren't being paid what you're worth.
- 33:18Why?
- 33:18Because negotiating isn't your thing.
- 33:21Even the best tech talent can get taken advantage of when negotiating their comp packages.
- 33:25Don't let this happen to you.
- 33:2610x Agent On Demand has negotiated more than $50 million worth of deals for senior level tech talent just like you.
- 33:33When you've got a job offer at hand or expecting one soon, contact 10x and they'll help you level the playing field.
- 33:39Just visit talkpython.fm/10x when you're ready to roll and mention Python for a three 30-minute consultation.
- 33:4610x Agent On Demand.
- 33:48You handle the tech, they'll handle the negotiation.
- 33:50Another thing, actually, I think this was a, wasn't a warning message.
- 33:56It was like an info message when I ran Flask recently that I had a virtual environment named .env.
- 34:01And it said, hey, we think we can help you with some files that are hanging out in this .env thing.
- 34:06Yeah.
- 34:07So maybe tell us about the python.env.
- 34:09Yeah.
- 34:09So as part of the CLI improvements, we also, previously when you were using the CLI, you had to kind of type these environment variables in every time you opened a terminal.
- 34:18So you had to tell it like export Flask app equals, you know, my app, export Flask app equals development.
- 34:23And so we integrated python.env, which is a library that reads these .env files and automatically sets up your environment variables based on it.
- 34:35So people can just have one of these sitting in their project.
- 34:37And they won't have to set up their terminal every time they start working on the project again.
- 34:43Yeah, that's really cool.
- 34:44One thing I recently learned is the script that activates virtual environments.
- 34:49You can export stuff from there.
- 34:52You know, you set every virtual environment.
- 34:53Go in there and sort of configure your virtual environment.
- 34:55So in addition to just having the packages you want, it also kind of kicks off with the right environment variables, which is handy.
- 35:02The downside of that, and we do have that listed in our CLI documentation.
- 35:07Like this is an option.
- 35:08You're using virtual lines, go edit your activate script.
- 35:11But the downside of that is if you have multiple people developing or if you're on multiple machines, you know, and you recreate your virtual line.
- 35:18If you suddenly don't have that stuff and so it doesn't work again.
- 35:21Right.
- 35:21Right.
- 35:22It's a pain in the CLI, sorry, in continuous integration.
- 35:25And also you can check your .flask env into source control, whereas you can't, you shouldn't check your virtual environment into.
- 35:32Yeah.
- 35:33If you've managed to check your virtual env into Git and it works somewhere else, that's amazing.
- 35:38Yeah, exactly.
- 35:40A lot of stuff has to line up just so for that dork, right?
- 35:43Nice.
- 35:44Okay.
- 35:44Another one, another big change.
- 35:45I thought this was pretty cool is it's got to help people when they're testing for performance.
- 35:50And how's my app going to behave when I ship it to production?
- 35:53Is the development server is now multi-threaded by default?
- 35:56Yeah.
- 35:57So the development server actually had threading previously pretty much for its entire existence, but you had to explicitly enable it.
- 36:04So you had to say like when you were starting, you had to say like threading equals true or something.
- 36:09Right.
- 36:10And so now people were just always running into things like, hey, I'm trying to serve some media and like make an API request at the same time.
- 36:19And suddenly it's hanging.
- 36:20Well, that's because the dev server would only handle one request at a time.
- 36:23But we decided to go, let's just enable threading by default.
- 36:27It makes some things more difficult to reason about, but debuggers nowadays are pretty good at figuring out, you know, what threads are running and where to do breakpoints and all that.
- 36:37I think it's a good change.
- 36:38I mean, we're living in a multi-threaded world, right?
- 36:40A multi-core world.
- 36:41That's actually one of the big kind of hidden bugs that needs, or not bugs, but things that needs to be improved in Fairkzweig now.
- 36:50Because we're threaded by default, Fairkzweig has this nice debugger that pops up the traceback and lets you interact with it when there's an error.
- 36:57But it only works in single threaded environments.
- 37:00It'll still output correctly.
- 37:04But if you have multiple requests going on at the same time and you try to interact with the traceback, you might just get like junk data back.
- 37:10And so figuring out how to get that working in a threaded environment is actually on my to-do list.
- 37:16It still works for us.
- 37:18Yeah.
- 37:18It's not like a huge issue.
- 37:19Yeah.
- 37:19How many people are actually interacting with the debugger and hitting concurrency at, you know, exactly that moment, right?
- 37:26Probably.
- 37:26Very few.
- 37:27I think we got a couple people who reported it.
- 37:31And I just said, you know, you just kind of try to make your thing synchronous when you're debugging a list.
- 37:35Right, right.
- 37:36Use this command line that makes it not threaded.
- 37:38Yeah.
- 37:40So there's still things to be fixed, but we're basically trying to improve the 80% case, right?
- 37:45Like the 80% of the time you're going to have this and then we can fix the, or whatever that's saying is, 90, 90, 10 or something.
- 37:52Yeah, yeah.
- 37:52Get people to fall into the best case scenario most of the time.
- 37:56Right.
- 37:57So another thing that changed is accessing missing keys from request.form.
- 38:02Yes.
- 38:02That was...
- 38:03That's one of your error message type things, right?
- 38:05Right.
- 38:06Yeah.
- 38:06So we had a couple of things.
- 38:07So basically the way Flask looked up error handlers and reported errors was improved.
- 38:14So it's more consistent in more cases.
- 38:16And as part of that, I noticed that...
- 38:19And this is an issue that comes up on Stack Overflow all the time is like, hey, I tried to access, you know, request.form name and I got a 400 error.
- 38:31Why?
- 38:32Well, the answer is because you didn't submit a form field called name.
- 38:38But we don't tell you that we...
- 38:40Like the dev server never told you that.
- 38:43I guess if you're deeply familiar with status codes, you would know that 400 means something is wrong with the data you submitted, but it's still not even obvious there, right?
- 38:53Yeah.
- 38:54So now when you're running in debug mode, the error, we still raise the same error, but I inject some extra information into it about like, hey, you tried to access this key and it wasn't there.
- 39:03So go check your HTML and see if it's...
- 39:07If you're sending what you expect.
- 39:08Yeah.
- 39:09That's cool.
- 39:10Like that could be the difference from...
- 39:11Oh yeah, of course.
- 39:12I'll check my HTML versus hunting Stack Overflow.
- 39:15Yeah.
- 39:16Now I know like Stack Overflow probably isn't the best metric for this, but like we still get plenty of questions about like,
- 39:23why am I getting a 400 error?
- 39:24Like I've even gotten questions with the error message saying you're missing this key right there in the question.
- 39:30So like I'm not going to, you know, solve everybody's problems, but it's a lot clearer.
- 39:33And that was basically the number one problem that I always saw.
- 39:36Yeah.
- 39:37I'm seeing it less at least.
- 39:38Yeah, it'll definitely be less.
- 39:40That's cool.
- 39:42I mean, you're never going to solve the problem of somebody just sees it doesn't work.
- 39:47I'm just going to Stack Overflow and pasting the error and not reading through it and thinking through it.
- 39:51Or, you know, maybe they're just so new they don't make sense of...
- 39:54They don't see what should be obvious.
- 39:55Sure.
- 39:55I mean, there's still a lot of information, even if that's at the bottom, you know.
- 39:59So I understand, obviously.
- 40:00Yeah.
- 40:01Yeah, yeah.
- 40:02For sure.
- 40:02Let's see.
- 40:03You changed error handlers a little bit.
- 40:05Like the thing that will run if, say, there's a 400 bad request or a 404 or something like that?
- 40:10That's more of an internal change.
- 40:11Like, I don't think most people noticed.
- 40:13But technically, when you've raised...
- 40:16You can register error handlers on Flask and on the blueprints inside of it so that when certain errors are raised, they'll be handled by those instead of causing a 500 exception, you know, to be sent to the browser.
- 40:28And in certain cases or for certain types of exceptions, the behavior was just kind of inconsistent.
- 40:33And so we kind of...
- 40:35We just went back and looked, like, how is this actually working?
- 40:38Oh, there's, like, this mess of different if statements.
- 40:40Well, let's just, like, simplify that.
- 40:43So there's, like, a strict set of rules that it goes through now and it's documented and all that.
- 40:47Yeah, that's cool.
- 40:47So one thing that you just mentioned that I think is worth touching on a little bit for the listeners, a lot of the frameworks, it's a little easier to partition your view methods into different files and categorize them and stuff.
- 41:01Because you just take a static decorator that comes out of, say, like, Pyramid.
- 41:04You say, at view config and you just drop it there.
- 41:06In Flask, you create the app and then you say app.route.
- 41:10And so in order to split that stuff apart, you have to pass that app around in certain ways.
- 41:15But then you also have blueprints, which really simplify that.
- 41:19Do you want to just tell people real quickly who maybe only know about app.route, about blueprints and, like, that problem solves?
- 41:24Yeah.
- 41:24So I mentioned the application factory pattern earlier, where you don't actually ever have an instance of your application when you're coding.
- 41:33You have a function that creates it.
- 41:34And that's actually the recommended way to use Flask in the official tutorial now is use an application factory because it solves a lot of problems that people run into, even if it's a little more confusing.
- 41:44But one of the problems with using that is, well, you can't just decorate your function, view function, with at app.route anymore because you don't have app.
- 41:52So instead, Flask has this thing called blueprints, which are basically ways to defer calling app.route.
- 42:01So you call blueprint.route.
- 42:04And that just kind of registers, like, hey, this is here.
- 42:07And now later, when you have your application and you register the blueprint with your application, take all those deferred registrations and perform them now.
- 42:16And so you don't have to have access to the application.
- 42:19You can split your code up into different modules so that all the stuff about users is over here and all the stuff about blog posts is over here.
- 42:28You don't have to worry about circular imports or any of that.
- 42:31Right.
- 42:32And that has been tricky.
- 42:33And I think the blueprint stuff is really beautiful.
- 42:35It just makes it so much easier to partition your code in a more healthy way for large apps.
- 42:40Yeah, it's a really good pattern.
- 42:41And that's why I tried to...
- 42:42It's something that confuses a lot of users.
- 42:44I think they expect more of it than it actually does.
- 42:48Like you said, it's a pretty straightforward, or it's a pretty simple pattern.
- 42:53It just defers calls.
- 42:55Yeah.
- 42:56So people are doing Flask and they don't know about blueprints.
- 42:59They should go spend the five minutes and learn about it.
- 43:01Yeah.
- 43:02Read the official tutorial.
- 43:03Flask.poku.org slash docs slash tutorial.
- 43:06It'll walk you through an application factory, making a blueprint, all that.
- 43:10Yeah.
- 43:10Yeah.
- 43:10Very cool.
- 43:11Another thing that changed in Flask 1.0 is the testing got a little easier.
- 43:15Testing.
- 43:16A test client having a JSON request and then also get JSON for response, right?
- 43:22This was kind of like another one of those like, hey, there's an inconsistency here.
- 43:27You could test JSON before.
- 43:28I mean, there's a lot of people did.
- 43:30But the request object that Flask gives you, like when requests come into your views, has this
- 43:36JSON property.
- 43:37And it basically automatically parses JSON from the request.
- 43:42Right.
- 43:43A dictionary pops out if it has JSON text inside.
- 43:46And so people kept expecting that to work when they were testing.
- 43:49So they would make a request with the test client, get a response object back.
- 43:52And unlike for the request object, the response object didn't have that.
- 43:57And so they'd call JSON.
- 43:57It wouldn't work.
- 43:59And then they would have to like go get the raw bytes and pass it to JSON.loads.
- 44:03And some people would use Flask JSON implementation.
- 44:06Some people would use Pythons.
- 44:08So we just made it consistent.
- 44:10So you can now get JSON from the response just like you can get it from the request body.
- 44:17And similarly, a lot of people expected.
- 44:19So we have this test client where you can just make a request.
- 44:23Like you can make a fake request without running the server.
- 44:25And it'll generate like the correct environment behind the scenes.
- 44:28And so you just say like I'm going to request, you know, slash users.
- 44:32And I'm going to pass, you know, name equals David to the form.
- 44:37But there was no clear way to.
- 44:38So it looked kind of like Python requests, the library, right?
- 44:42Like so you would make it like requests.get, you know, data equals name equals David, right?
- 44:47But so people were expecting it to kind of work like requests, be able to pass JSON equals, which you couldn't do.
- 44:53So you had to encode the JSON yourself.
- 44:55And so now you can just, if you want to test your JSON API, you can use the test client and just do JSON equals this data structure.
- 45:03Yeah, that's cool.
- 45:04Another thing around that is the test CLI runner.
- 45:08Oh, right.
- 45:08Yeah.
- 45:09So, so there's another testing thing.
- 45:11So we have this test client, which makes requests, but we didn't really ever document how to test CLI commands.
- 45:18And I mean, one of the, one of the selling points of the Flask CLI is that you can add your own commands.
- 45:24So if you want to like add a user management command, like, hey, have a create user command that I can run on the background to like add the admin user when I'm deploying.
- 45:33There was no way to really test that.
- 45:35Like it was documented in clicks documentation.
- 45:37But even with that, it wasn't really clear how to get Flask, Flask's like CLI object working in a test framework.
- 45:45So we have, you know, have this test CLI runner that kind of mirrors the test client.
- 45:50So you can test the CLI code.
- 45:52Yeah, that's great.
- 45:54So I feel like that's the main items that I saw that are pretty interesting.
- 45:58Anything else that you want to tell people about 1.0?
- 46:01I think that was the big stuff.
- 46:02Yeah, I think so as well.
- 46:04I mean, you can go look at the full changelog.
- 46:06It's pretty impressive.
- 46:07I think it's like two pages long on my screen vertically.
- 46:10That's awesome.
- 46:12But yeah, these seem like a lot of great changes.
- 46:15And what do you say for people who are thinking about upgrading, like maybe they've got Flask
- 46:19equal equal, you know, 0.11.
- 46:21They're afraid of change.
- 46:23And they don't want to change it.
- 46:24Should they change?
- 46:26And what would they get from doing so?
- 46:27They should absolutely upgrade, especially if they're on 0.11, because that's a couple of
- 46:33years.
- 46:33I was thinking of a pretty out of date version.
- 46:35Yeah.
- 46:35When I said that.
- 46:35Yeah, one of the reasons to upgrade if nothing else is just to continue to get support.
- 46:39Just kind of due to the size of our organization, we don't really offer support on old versions.
- 46:45Like I will do security fixes for 0.12 until 1.1 comes out.
- 46:50But nothing besides that.
- 46:53Right.
- 46:54So if there's a problem and somebody has a 0.11, the official answer is you want to fix
- 46:59that, make that problem go away, you install one, right?
- 47:01Yes, install one.
- 47:03And even if you're on 0.12, there's no real reason to stay on it at this point.
- 47:06Luckily, what I've heard from various users, like when I was at PyCon, Flask 1.0 had just
- 47:12been released and people were already telling me, yeah, I upgraded.
- 47:15And it was literally just changing the version number.
- 47:17Everything worked.
- 47:18Right.
- 47:19There are some things that changed a little bit, but they're rarer cases and it's documented
- 47:26on the change log and it's pretty obvious when it fails, like, oh, this thing got renamed.
- 47:30Right.
- 47:31So there's not a whole lot of work to upgrading.
- 47:33No.
- 47:33All right.
- 47:34Excellent.
- 47:34That's good to hear.
- 47:35So one of the things that I thought was interesting is you talked about on the Pallet's organization
- 47:42website about being part of the PSF's fiscal sponsorship program.
- 47:47If people want to support Flask, maybe you want to tell them about that program and how
- 47:50they can help.
- 47:51Sure.
- 47:51It's really cool.
- 47:53It's also really new.
- 47:54So I might not be the best spokesperson for it yet.
- 47:57I hadn't heard of it before.
- 47:58I'm like, oh, we should talk about this just so people know it's out there.
- 48:00Yeah.
- 48:01So, I mean, this is a little bit of advertising for the PSF also, but they have this program
- 48:06called the fiscal sponsorship program.
- 48:08They were mostly using it for meetups at the time that I tried to get in.
- 48:12And basically what it is, is you submit your organization and they accept you.
- 48:18Or if they accept you, you become part of the PSF essentially.
- 48:21So you gain their, their nonprofit status.
- 48:25They will help you out with certain logistics and they will also set up a donation page for
- 48:31you and a bank account for you that they'll manage, which was great for me because it's
- 48:36not something that I have any experience with.
- 48:38And, but I did want to be able to start taking donations for Flask.
- 48:42So yeah, I've reached out to them because I saw that somebody pointed out this program.
- 48:47And when I reached out to them almost a year and a half ago now, I think they only, they
- 48:51didn't have this set up for developer organizations like pallets yet.
- 48:56So we were kind of their test project and we got into this program right as a, right before
- 49:02PyCon.
- 49:02And then I think they've accepted a couple more projects since then or kind of like in parallel
- 49:07with us.
- 49:08So we now have a donations page.
- 49:11You can go to palletsprojects.com slash donate, and that'll redirect you to the right place.
- 49:16Let's see, take PayPal or checks to one time or recurring payments.
- 49:20And we're basically just trying to raise money to support the community.
- 49:24And I'm not a hundred percent sure what that means yet.
- 49:27I have some vague plans.
- 49:29We want to be able to support maybe if you want to have a meetup that sprints on Flask,
- 49:34for example, we can sponsor that.
- 49:35You know, maybe we sponsored pizza or something, right?
- 49:38Or recognizing people, you know, outstanding contributors in the community, sort of like Google
- 49:45does, right?
- 49:45So Google has that.
- 49:46I don't know the name of the program, but they recognize developers every year.
- 49:49And so we were thinking that would be a cool way to do it.
- 49:51And maybe, you know, further down the line, being able to have a Flask conference.
- 49:56And besides...
- 49:57Really good.
- 49:58Yeah.
- 49:58Yeah.
- 49:59So those are kind of like outward facing.
- 50:01And then the other thing donations would support be getting the current maintainers to more conferences
- 50:07so we can run sprints in person and supporting our infrastructure and all that sort of thing.
- 50:12Yeah.
- 50:13I know.
- 50:13I'm pretty sure it was NumPy that had this, like one of the scientific groups basically...
- 50:19Oh no, I think it was PyPy.
- 50:21Anyway, one of these groups, basically a lot of contributors had never met and they had taken
- 50:25their donations and they use it to get the contributors physically together.
- 50:29Maybe like you said, at like another conference, like PyCon US or EuroPython or something.
- 50:33And it seemed like it made a really big difference.
- 50:35That's absolutely something I want to do eventually.
- 50:37Like I've never met Armin or Adrian or Marcus in person who are the other core contributors,
- 50:44mostly because they're in Europe and I'm over in California.
- 50:48So it's a little difficult to find the time and money to do that.
- 50:51And being able to get us all in the same room, I think would be very productive.
- 50:55Yeah, I think so as well.
- 50:56And let me just put a plea out there or a comment out there for folks who work for companies
- 51:02that are large, successful companies that depend on their technology and that technology
- 51:10significantly involves Flask.
- 51:11I think there's so many large, multi-billion dollar companies that are built on Python and
- 51:19some of its libraries and they don't necessarily contribute anything back.
- 51:23If those companies could all just contribute, it's a very, very small amount of what they
- 51:27pay their developers to keep the projects they depend upon healthy.
- 51:31That would go a huge, huge way.
- 51:33So people are out there in that situation.
- 51:35I'm not, but if they can make that happen, that'd be awesome.
- 51:38Absolutely.
- 51:39I was reaching out.
- 51:41That was basically my entire PyCon when I wasn't in open spaces or sprints was being on
- 51:45the floor going to, I actually printed out business cards, not for myself, but for pallets
- 51:50with the donate, the donate link on it.
- 51:53And I was handing them out to every single company and like saying like, Hey, do you use
- 51:57Flask?
- 51:57Turns out like 80% of the companies at PyCon use Flask or Jinja or Click.
- 52:03Yeah.
- 52:04And if they all just recurrently added a hundred or a thousand dollars, right?
- 52:08Like that would just change, change things dramatically.
- 52:10I'm sure.
- 52:11Oh, sure.
- 52:11If everybody added a hundred thousand dollars, that'd be great.
- 52:14A hundred or a thousand.
- 52:16Obviously.
- 52:18I don't know what we would do with that much.
- 52:20Gosh.
- 52:20Don't do that all at once.
- 52:21Let me, give me a year to ramp up.
- 52:23Yeah, exactly.
- 52:24It's you'll find David on an eye, his own personal Island.
- 52:27He's no longer working on Flask.
- 52:29No, just kidding.
- 52:30Now that'd be awesome.
- 52:31If we got more support for Flask and other projects that are in the same, same boat,
- 52:35basically.
- 52:36Absolutely.
- 52:36I think it's really important just to recognize the tools you're using and, you know, support
- 52:41those, support the maintainers that are already working really hard on them.
- 52:44And so, yeah, we're, we're starting that we've gotten, I didn't really advertise it that much
- 52:48after PyCon, but we've gotten a significant number of donations already just from personal
- 52:52donations.
- 52:53And it's really cool to see those notifications come in.
- 52:55You know, I see a little notification, like $5 was donated every time it happens.
- 53:00And it's, it's really nice to see that.
- 53:02Cause a lot of the times my experience with maintaining is, oh,
- 53:06there's a new bug, go fix it and stuff.
- 53:07You know, it's never anything like really positive.
- 53:09Somebody being impatient and frustrated and then they've gotten to you finally.
- 53:13And now you're frustration.
- 53:15Right.
- 53:16Yeah.
- 53:16Yeah.
- 53:17I hear you.
- 53:18So let me ask, I guess sort of a few closing thoughts here.
- 53:22Like what's next?
- 53:23Like you've got one out now, now where are you headed?
- 53:26I think I said this earlier, but Flask one, Oh, all the features that I want at least
- 53:31are in there.
- 53:32And I think most of the features that people ask for are easy to do with extensions at this
- 53:38point.
- 53:38That's not to say we're not going to like add anything to Flask or, but you know, it's
- 53:42mostly like, like I said, how can we improve people's experience with Flask?
- 53:46How can we make it easier for them to learn and work with it on a day-to-day basis?
- 53:50So improving documentation, identifying better error messages, writing more tutorials, writing
- 53:56better tests.
- 53:57That's what a lot of the focus on Flask is.
- 53:59There's still a lot of focus on Verixdweig and Click and Jinja for actual bugs and features
- 54:06to get in.
- 54:06Verixdweig is just never ending because there's always more HTTP RFCs coming out, you know,
- 54:11changes in subtle ways.
- 54:14It's my favorite.
- 54:15I've gotten so good at reading RFCs now and I'm still, I still don't like it, but.
- 54:19I'm sure.
- 54:20I'm sure.
- 54:20It's pretty dry stuff.
- 54:21So I guess the final question around this is when will I be able, if, will I ever be able
- 54:28to write, let me rephrase it that way.
- 54:29Will I ever be able to write async def index?
- 54:34You know, app route, async def index.
- 54:38Yes.
- 54:39I've committed to this kind of publicly, but in other places, but yes, we do want to have
- 54:45async support in Flask and Verixdweig.
- 54:47That's awesome.
- 54:48Getting there is going to be really difficult because we also want to maintain compatibility
- 54:53with Python 2.7 for at least another year and a half.
- 54:57We want to maintain compatibility with Python 3.4.
- 55:00And I think if what you told people was you have to wait until we drop support for 2.7
- 55:05and 3.4, that just knowing that it is coming actually would probably.
- 55:09I mean, honestly, even if we don't say that it's probably going to take that long to get
- 55:14there.
- 55:15There's a lot of work to do.
- 55:16Verixdweig is very, it makes a lot of assumptions behind the scenes about the WSGI environment.
- 55:22I have gotten some contributors who are interested in working on that.
- 55:25So there's an effort in Verixdweig to make it sans IO, which means separating the IO from
- 55:31the parsing so that we can kind of plug in different.
- 55:34Right.
- 55:34Then you can plug in an async layer maybe right there without really changing much.
- 55:37Right.
- 55:38And then on the Flask side of things, we're looking at ways to kind of look kind of like
- 55:43the two to three migration tool.
- 55:45We're trying to look at some sort of async to sync migration tool where we can write async
- 55:49code and get a version that can also work with sync code.
- 55:53Yeah.
- 55:54I think there's been some work on that in your all lib3.
- 55:56Nice.
- 55:57Have you seen the work they're doing with Quart?
- 55:59Yeah.
- 56:00So I actually reached out to Philip, who's the author of that, a couple weeks ago and said
- 56:07like, hey, you know, Quart can still be its own thing.
- 56:10But I know you were trying to be Flask compatible.
- 56:12Would you be interested in just making Flask async?
- 56:15And he was on board with that.
- 56:17I've met with him a couple of times.
- 56:19He's still working on Quart, obviously, but he's going to at least be there giving input
- 56:25about how we can get Flask to be in that same place.
- 56:28So yeah, it's definitely a cool project and excited to work on it.
- 56:32Yeah.
- 56:32If that sounds interesting, people don't know anything about it.
- 56:35I interviewed Philip Jones about Quart on episode 147 a little while ago.
- 56:39So check it out.
- 56:40Okay.
- 56:41Yeah.
- 56:42Yeah.
- 56:42I've played with it a little bit and it's pretty solid.
- 56:45It seems like if you could take kind of what he's doing and where you're going and blend it.
- 56:50Yeah.
- 56:51The nice thing he has going for him is he can just say, I only want to support Python 3.6
- 56:56and above.
- 56:57Yep.
- 56:57Yep.
- 56:58And I don't want to support sync at all.
- 57:00Or like I'll support sync in, you know, some worker threat executors, but I'm all async.
- 57:06And that's just not like we have to be a lot more deliberate about how we handle backwards
- 57:11compatibility in Flask.
- 57:12We will get there.
- 57:14Well, I'm really encouraged to hear that you're on that path, even if that path is a long journey.
- 57:20Yeah.
- 57:20And so that's definitely if some people are interested in contributing or using async code and want it in Flask,
- 57:26like that's definitely a place where I could use more contributors also.
- 57:29So.
- 57:29Okay.
- 57:30Check it out.
- 57:31Awesome.
- 57:32All right.
- 57:33Well, I think that's probably, we're going to leave it for Flask, but it's been great to get caught up with what you're up to.
- 57:38Yeah.
- 57:39Thanks for having me.
- 57:40You bet.
- 57:41You're not out of here without answering the two final questions though.
- 57:43First of all, if you're going to write some, some Flask code, what editor do you use?
- 57:47PyTerm.
- 57:48PyTerm.
- 57:49Professional.
- 57:49I love it.
- 57:51I'm right there with you.
- 57:52All right.
- 57:52And then notable PyPI package.
- 57:54We talked about six already.
- 57:55Flask, Werkzeug, and so on.
- 57:57Other ones that maybe people don't know about it.
- 57:59You're like, oh, you should totally check out this.
- 58:02So yeah, I gave this one a little bit of thought.
- 58:04I don't actually have the opportunity to use a lot of PyPI packages, but the ones that have
- 58:09been kind of in my awareness lately are one called Authlib.
- 58:14Okay.
- 58:15Okay.
- 58:16A-U-T-H-Lib.
- 58:17Yeah.
- 58:18Yeah.
- 58:18And that's like a new, very thorough implementation of OAuth and OpenID and OAuth2 client and server
- 58:27for Flask and Django and has all sorts of integrations with different existing OAuth implementations
- 58:35on different social sites.
- 58:36And so-
- 58:37Oh yeah.
- 58:38That looks cool.
- 58:38It's pretty cool.
- 58:40If you go look at the documentation, it's pretty incredible how thorough it is in terms
- 58:44of what standards it's supporting and all that.
- 58:48And the other one I'm looking at is Flask Talisman, which is basically-
- 58:53I don't know that one.
- 58:53What's that about?
- 58:53This one's really important.
- 58:55I think a lot of people don't really think about what it solves.
- 58:57And what it does is there's all these different headers that you can send in your responses to
- 59:04browsers that will tell the browser how to be secure.
- 59:07What stuff it's allowed to do and what stuff it should block from happening.
- 59:11And there's a lot of them out there.
- 59:14There's like maybe not 20, but close to 20 different headers and different configurations
- 59:18of them.
- 59:19Flask Talisman will set all this up for you for the most part and tell you like, it'll give
- 59:23you the secure defaults.
- 59:24And all you do basically is just wrap your application in the Talisman extension and it's done.
- 59:29Your application is just more secure.
- 59:32And I really like that.
- 59:33I'm just plugging it into all my applications now.
- 59:36Oh, that's cool.
- 59:36It looks like it comes from Google as well, which is pretty nice.
- 59:39Those are two really great recommendations there.
- 59:42And I'm definitely going to play a little more with AuthLab.
- 59:44I got to get some single sign on stuff going on.
- 59:46So that'll be great.
- 59:47Final call to action.
- 59:48People now know there's a Flask 1.0.
- 59:51What should they do?
- 59:52There's Flask 1.0.
- 59:53Go upgrade.
- 59:54Watch us on GitHub and start contributing to issues.
- 59:58Donate.
- 59:59Go to palletsprojects.com slash donate and help the maintainers all meet up maybe.
- 1:00:05That's awesome.
- 1:00:06All right.
- 1:00:06David, thanks for sharing all of what you've been up to.
- 1:00:09It's really great work.
- 1:00:09And I'm super excited to see Flask moving forward like it is.
- 1:00:13Yeah.
- 1:00:14Thanks for having me on, Michael.
- 1:00:15You bet.
- 1:00:15Talk to you later.
- 1:00:18This has been another episode of Talk Python To Me.
- 1:00:21Our guest on this episode has been David Lord, and it's been brought to you by Linode and 10x Agent on Demand.
- 1:00:27Linode is bulletproof hosting for whatever you're building with Python.
- 1:00:31Get four months free at talkpython.fm/Linode.
- 1:00:35That's L-I-N-O-D-E.
- 1:00:38When you've got a job offer in hand or are expecting one soon, contact 10x Agent on Demand, and they'll help you get the salary you deserve.
- 1:00:45Just visit talkpython.fm/10x and mention Python.
- 1:00:49Want to level up your Python?
- 1:00:51If you're just getting started, try my Python jumpstart by building 10 apps or our brand new 100 days of code in Python.
- 1:00:58And if you're interested in more than one course, be sure to check out the Everything Bundle.
- 1:01:01It's like a subscription that never expires.
- 1:01:04Be sure to subscribe to the show.
- 1:01:06Open your favorite podcatcher and search for Python.
- 1:01:08We should be right at the top.
- 1:01:09You can also find the iTunes feed at /itunes, Google Play feed at /play, and direct RSS feed at /rss on talkpython.fm.
- 1:01:19This is your host, Michael Kennedy.
- 1:01:21Thanks so much for listening.
- 1:01:22I really appreciate it.
- 1:01:23Now, get out there and write some Python code.