 All right, so I'm going to admit I've never met Diane in person. I've only seen the picture she has on her Twitter account and in chat. So I have been dying for this moment to see if the hair matches the picture. It does. And it's amazing. Paul Morty who talked during the keynote is known for having a mohawk that is colored. Any kind of gradient from green to yellow or purple to pink or something like that. And today you had a hat on and I was legitimately disappointed. So I'm looking forward to this. There's going to be a point during your talk where I pull my daughter into show her because she's going to think that's amazing. And none of this is related to Python. So with that introduction, I'm going to let Diana take over and she's here to talk about flask. Hello everyone. I'm going to share my screen and yeah, this is this is a good all mohawk. So yeah, the title of my talk today is how much of a micro framework. And it's exciting. You can check the slides on slides.com forward slash super Diana forward slash plus micro. And I'd like to introduce myself. So you know who am I? My name is Diana Rodriguez. I'm a Python developer advocate at Vonage. I'm also all those things you see in there. But the most important part is that I'm someone who learns new things every single day. By the way, I love the community. I love to get in touch with people. And so feel free to follow me or DM me on Twitter. And that's my website super guy.dev. And yeah, this is exciting. And now that we know who am I, I'd like to also remind everyone about what am I not? And I don't know if you know this lady, but this is the Oracle, particularly from the matrix. So I'm not the Oracle and this means I don't know all the answers. And excuse me, despite of, you know, being in this industry for 20 years, there's so much that can be learned every day. Apart from all this introduction, I would also love to warn you that this talk is framework agnostic and that I promote the weapon of choice philosophy, which means whatever tool you use is the best as long as it does the job. I'm not trying to mob anyone into the cult of, you know, the gospel of flask or promote any framework wars or anything. And I will be using obvious examples. And I've learned throughout my entire career that simplicity goes a long way. So this is this is a talk for all audiences beginner and advanced. And I think these are things that we should all think about and remember. Right. So to give you some context, I'm going to be comparing the two. Well, I would say the one of the two most picked the most popular frameworks. You know, in the Python scene, there's flask, the one I'm going to talk about and Django. And Django is one of the most popular and common frameworks using Python. And it's a full fledged suite in comparison to flask. So I need I need a comparison point. And well, for those who are not familiar with Django, it's a Python based free and open source framework. It follows the model template view architectural pattern. And it's amazing for when we want to create complex database during websites. It is used widely around the world. And it's 100% awesome. And then there's flask. It's a Python micro framework. And well, I like to question the use of micro framework. But we'll talk about it in a bit. So it's based in work. I can never pronounce that properly, you know. Ginger 2 for templating and the bestest intentions. And I say that because those who created flask actually had the best intentions in heart. And I like flask because we can build amazing applications. We can build very simple APIs. And the simplicity again is what totally drove me to flask. Now, if we think of micro framework, I like the Avengers. And I love to compare flask or the concept of flask as a micro framework. Oh, my glasses are cloudy. To Dr. Strange. Dr. Strange is my most favorite Avenger. So I'd like to compare it to Dr. Strange. But if we actually get to the real business, this is the sample architecture of a micro framework. So we have the very basics to make it happen. If you're more into visual comparisons, a micro framework could be seen as Lego blocks. You can add or take at will according to your needs. Now, if we compare this to the Django architecture, and I'm not going to go in depth to what you see. This is what the architecture looks like. We could compare that to the All Blacks from New Zealand. It's a full team with amazing players. And, you know, we made the choice based on what we want to build. Do we want to have the whole team? Do we need a whole team carrying out all these team tasks? Or we do just need the ball, right? That's basically my bestest comparison. If we see how simple Flask is and why I think it's amazing because it's super friendly. It's beginner friendly. One of the things that I like the most is that you can have a Hello World app in less than 10 lines and no complication. It is extremely readable. The syntax is beautiful. And if we think about people who are learning from scratch, it's pretty friendly to understand what's going on. So we're basically instantiating Flask. And then we have our write decorators where we can define the route and method. If it applies, then we write our logic and then we run our app in main. And that's basically how we get to this. And I left it with PyLadies because I gave a similar talk to PyLadies. And yeah, it looks awesome. So for those who write APIs without frameworks, Flask also offers simplicity and performance. This is basically what you need to get started. Now let's see. Every framework and every tool we use has its pros and cons. And we're going to talk about that. So for the pros, the learning curve is not steep at all. I consider Flask a good framework to start with Python. And if you're not into Python and you're getting into this side of the world is also a good way to start. It's production ready, which means you can test your apps. You can basically deploy your apps. And check them locally as well, run them locally. The writing syntax is amazing. It helps me personally organize my code in a better way. It also supports sessions and cookies. It is extensible because you can add or take at will. And something that could be seen often as a disadvantage, but to my own point of view is an advantage. It doesn't come with any baiting or an admin interface, which means it's lightweight. And again, we're going back to whether we need the whole team for a smaller app or we just need the ball or one player. And of course, the documentation is excellent. Now, if we think about cons, will Flask has none? No, I'm joking. It can be seen a bit complex with big apps. Maybe, you know, too many moving parts can consume a lot of development time. And this is when we say, well, we have to choose wisely what we do. The community is very small in comparison to Django. But, you know, yeah, don't let that discourage you because this is the opportunity to create something new. If there's nothing, if there's no answer to your question, was it a time to think of solutions? I propose them and the community will benefit from it. So in general, performance and freedom of choice, many libraries and modules and the freedom to create new solutions for the community in general. So, after this, the most common questions I get are, is Flask for small projects only? I don't think so. In the world of Flask, there are a lot of dependencies that will help us create robust and scalable web projects. So do you want to connect to a database? You can implement the ORM of your choice. Do you want to version your API? There's sure a library to meet those needs. Do you want to integrate migrations and an interactive shell for your models? You can do that. I personally recommend Flask Manager. And the community is actually very active in this particular aspect. So there are many things that are native to Django that you can find them as Flask dependencies. And again, if not, what a grand opportunity to create something new. Another common question is, why is it called a micro framework? Well, let's not get carried away when we see micro framework. The only reason why Flask is called a micro framework is because it comes with the bare minimum. So you can start creating on top of it. Like I said, sometimes our needs are very particular and we don't need a full-fledged suite within that main interface with a baiting ORM and all these utilities or extra features that could seem unnecessary for certain kinds of apps. So having the freedom to add or take it will actually make it grand. That's why it's a micro framework. Sorry, I can't get it away. I started talking about it and I get excited. Another common question is, can you do everything Django does? Everything you do with Django, you can do it with Flask. So you can define routes, you can work with worms, you can render templates, send emails, define unit tests and everything else. And whatever doesn't exist, you can create it. When should I use Flask? Instead of Django, I'd say, so Flask is a very light framework. If you're working with microservices and if you're working with IoT-related projects, Flask, you can actually run a Flask server in a Raspberry Pi and a Pi Zero as well. So yeah, there you go. If we move on, let's go to the next stage. So full stack Flask, this is interesting. But yeah, it is possible too. We can use Flask with all popular front-end frameworks. I've had the pleasure to work with all of them actually. So I have applications with React and Flask. Flask and Angular, can you believe it? Flask and View and I will leave you a link in the resources slide, Flask and Spell. And you know what? It works like a charm. But it's been a grand sales pitch so far. Let's see Flask in action. And I'll give you some context. There you have a URL for an application that I built for myself. I'll tell you a bit more about it. It basically uses Ginger for templating and I'm using materialized CSS. And to give you some context, I am diabetic so I belong to the Forty Pancreas Club. If you go to that URL, dianox.superni.dev, you'll see something like this. And that is a dashboard that has data from a sensor that I have here in my arm that is constantly measuring my glucose levels. This dashboard is a web-based CGM or continuous glucose monitor. It's called NightScout and it shows glucose data in real time. Values are predicted 30 minutes ahead using another regressive second order model. This server reads from a Mongo database containing data from the sensor and then I have the possibility of generating alarms for high and low values. And that's grand. What happens? So I have a sensor and it goes to my phone and it also goes to this dashboard and based on that data I can make better dosing decisions. And I have a wireless pump. Ah, Omnipod. That's what you see in there. The problem is that although my phone and whatever devices they have alarms but in moments of crisis it is very difficult for me to hear them. When I'm asleep, when I'm working, you know, the world can end and the only thing that I can actually hear that will wake me up or if I'm not feeling well is when my phone rings. So the idea was to make my life and the lives of those fellow diabetics who have my same struggles much easier. Taking advantage of the simplicity of Flask and I'm adding the use of Vonage APIs. But how? Well, we have range of values. These are the low and high values for myself but they're pretty standard. For Europe, values are measured in millimoles per liter. In the Americas it's milligrams per deciliter so this app can handle both. You can configure that. And then we have the elements of my mobile phone. I can always hear it. So using two communication APIs from Vonage, I can make this happen. I'm going to use the SMS invoice APIs to notify myself and my emergency contacts of the irregular situations with my blood sugar levels. Which means, at first, if there's anything going on with those blood sugar levels, it's going to call me and it's going to tell me, Diana, you're high. Your blood sugar level is, I don't know, 140. Let's see live, how are we? We are at 107, which is pretty good. So if I don't pick up, it will call my mom, which is the next emergency contact. And if my mom doesn't pick up, I can add up to five emergency contacts and they will get the call if either of them don't pick up. And if no one picks up, they will all get a notified by text message. If my dashboard is offline, they will also get a message saying, hey, Diana's night scout is offline and then someone will contact me. And this is particularly useful because if I became unresponsive in the middle of the night and someone gets a call, they normally know that I'm at home and if I need assistance, someone can call 911. So what this does is it grabs readings for the last 60 minutes or any given time frequency through a Python thread with a scheduler. If ranges are below or higher than what is configured through environment variables, it fires an alert. There's also an alert, like I said, if there are no readings, like if it's offline. And then a second scheduler can be used to obtain fresh data. And this is it. It's a simple Flask app that allows me to log in and configure my details. And in this case, the easiest way to access was using Google authentication with Firebase. And I know the design is pretty simple. I was in a bit of a rush, but here you can see that I'm configuring the endpoint for the entries to grab the glucose readings data. I can configure my phone number to receive the calls. Then an emergency contact. This is my mom in this case and up to five additional contacts. Let's have a very quick run through on the technical details that may develop in this app an enjoyable experience. And also, if you think of any features that could be added to improve this app, please reach out. There's going to be a grand thing, a grand repo for October 1st, because adding features is not as difficult. It's not complicated enough. Make sure I've documented the APIs pretty well and offer documentation also on the development process. So I even have a tutorial that I will share with you on how I developed this app. So let's go through these details very simple. For views, we use Ginger as a template engine HTML, CSS, and JavaScript. And here we have a pound template defining content blocks to be used by children templates. And these blocks, sorry, will display the code from those templates. Something else to note is the URL for function to point to JavaScript and CSS in our static folder, which is a very comfortable and elegant way to do so. And then here we have that login screen that obviously I didn't add the whole thing, but just to show you a little bit what it looks like. So here we can see how login inherits from the main layout template. And then the renderer will load layout with whatever variations we add to our login file. And these variants will be defined within the blocks we send in layout. For example, I'm using the head block. And then boom, I added my code. On the Python side of things, again, one of the things that I love the most about this, about Flask is that you can specify the right and the method if applicable and then write your logic. So when you're seeing your code, you can actually read through in a friendly and organized way. And at the end of the day, we don't want to write cryptic code. I think the best way or the best thing we have to offer to the community, to users, to anyone who wants to work in our projects is clean and readable code. And with Flask, we have that opportunity out of the box. But if you want to know more about how I built this app in Dev, because it's actually a two-part tutorial, instead of going to that super long URL, you can go to nexmo.dev forward slash night scout. That's nexmo.dev forward slash night scout. It's the same. I will leave the links anyway. And obviously, if you want to contribute to that repository for Hectoverfest, I encourage you to do so. I think that as the face of the Python SDK advantage, I think we're going to be giving some incentives. Also, if you like some credits to start testing the APIs and check them out, please reach out. I am more than glad to give you all the tools that you need to explore these APIs and to also contribute with this project that is benefiting diabetic patients. So we're in the tech for a good challenge. Another thing I'd like to show you, and this is work in progress. If you want to see how things are going, obviously, this is work in progress, and it's been a while since the last time I did it. But it's a karaoke room. It's basically, yeah, an online karaoke. You can basically call a list, and choose from a list, and whoever you invite will get to sing. And I'm in the process of organizing how people are going to display. So if you want to check that repo out as well, it's a good way to show how Flask and React and our video API can interact. So I'm super excited. In conclusion, so Flask is definitely an awesome option if you're starting your journey with Python, it is a great option as well. Like I said, the learning curve is not steep at all. I like it because it's pretty readable. And the community is actually very friendly. I have to say about the Python community overall. I've had the most amazing experience. It's been 20 years for me developing. And since day one, things have been amazing. Again, Flask is definitely not limited to small projects only. It just depends, again, on your choice of how much time are you going to be using to develop your applications, whether you need a solution that comes with everything baked in, or if you want to have that granularity to control how you do things, it's up to you. I just personally like the freedom of choice if we can call it that way. Of course, you can add or take at will to meet your needs. So again, if you need something very minimal, say you're writing an API, it works grand because it's just what you need. Something else, once you gain proficiency with Flask, moving to Django will be very easy, or maybe you will need to move it all. So if we think of Flask as a micro framework, remember what I said at the beginning? I think more in terms of a mighty framework, and this is why I relate it to Doctor Strange so much. If you'd like some resources, I'm adding a tutorial. It wasn't written by me. It's by Alex Krebrea, and it's a grand tutorial on writing apps with Svelte and Flask. I loved it. There are also some resources with view on Flask, repository with everything Flask, and then some tutorials, and that URL is actually pasted twice. I guess I got really excited while I was doing this, and well, the slides URL. Thank you very much for this opportunity. I really loved speaking to you all, and again, if you want to reach out, you can go to superdye.dev, or you can message me on Twitter, and here's the resources slide again. Like Looney Tunes says, that's all folks. Not quite all yet. I do have a question I want you to ask, or I want you to answer, I should say, and I'm glad you stopped on this slide. I've definitely done these kind of talks before. I saw your schedule on your website, and it kind of bonkers how many talks you had these days. I said earlier, like the fall season is kind of crazy. So Berz asking, do you Flask folks often use ORM, or is it just straight SQL? I know personally I've been using SQL Alchemy. It's the best choice, definitely. I would say I recommend SQL Alchemy. Above everything. So I come from the OpenShift world, where I'm typically demoing something where you don't necessarily have a clean startup of, my database is up and completely running, and then my application comes up. I've done demos where it's my applications up and running in this degraded mode, and then the database may pop up and get discovered, and I found that SQL Alchemy handles that kind of the smoothest. And it's arguable if that's either anywhere from bad design to cloud-native design, where you've got this kind of walkiness going on at any event. Thank you. That was, I've done demos. I've seen Hello World demos, you know, incountable at this point. And seeing this very specific, very personal project was a really cool addition to this. I think everyone could wrap their head around it. I don't know if you've been keeping an eye on chat. I've asked the questions, but definitely scroll through because you've got quite a number of compliments on your slides. I can personally vouch for that as well. I did Matrix and MCU and all of this nerdy stuff. You fit in extremely well with the kind of nerd that I am. So that was really cool. You got a lot of good feedback on that. Thank you again. I'll ask before you completely disconnect if you can. Just post, I posted your night scout link. I was trying to type in ones as they went. And I ended up getting distracted as I was watching the talk and I'm like, oh, shit, I should be typing. So if you could just fill in a couple of links so people can click on them, I'd appreciate it. Definitely, definitely. I'll do. And again, sorry to take this minute. Think of October first. If you want to contribute to this repository, I will post the links. I'd be more than glad to give you everything you need to get started with that, including credits for the launch APIs. It was an honor to be here. Thank you so much. Awesome. Thank you very open thirsty. This is the kind of thing we want to push. So again, thank you super. Thank you so much for this. This is really cool. I really appreciate it.