A microservice skeleton
So far in this chapter, we've looked at how Flask works, and at most of the built-in features it provides--and we will be using them throughout this book.
One topic we have not covered yet is how to organize the code in your projects, and how to instantiate your Flask app. Every example so far used a single Python module and the app.run() call to run the service.
Having everything in a module is, of course, a terrible idea unless your code is just a few lines. And since we will want to release and deploy the code, it's better to have it inside a Python package so that we can use standard packaging tools like Pip and Setuptools.
It's also a good idea to organize views into blueprints, and have one module per blueprint. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access