A
A
Alexander Davydov2013-03-23 16:48:25
Python
Alexander Davydov, 2013-03-23 16:48:25

Flask for big projects

Does anyone use this microframework for large projects? Share your experience.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
realduke, 2013-03-23
@realduke

Not sure what exactly you are interested in!
Flask is no different from other Python frameworks. If you use Flask + SQLAlchemy + WTForms, then consider it the same Django, only without contrib and admin panel. Initially, you need to be ready to independently create the organization of the project structure, i.e. where to put the configs, where are the models, where are the tests, etc. There are several draft projects that make this easier.
A few related links:
github.com/mitsuhiko/flask/wiki/Large-app-how-to
github.com/swaroopch/flask-boilerplate
github.com/semirook/flask-kit
github.com/imlucas/flask-tool
github .com/klen/Flask-Foundation
Flask has quite a few extensions right now, checked out here flask.pocoo.org/extensions/. Many more can be found here crate.io/?has_releases=on&q=flask . It is recommended, of course, to take into account that some may be crookedly written or obsolete.
You can still search for ready-made applications by the design of projects. They are here flask.pocoo.org/community/poweredby/ , the ones with the source. There is a lot more on github, you can search for imports where Flask is used, in the simplest case, something like github.com/search?l=Python&q=from+flask&ref=searchresults&type=Repositories .

R
realduke, 2013-03-23
@realduke

Well, I will also add that the opinion that Flask is not suitable for large projects is a delusion. Of course, the phrase “big project” can be interpreted in different ways, a project can be with a very large code base, or it can be quite heavily loaded, maybe some other meaning can be put in, I don’t know. In Flask, there is only one limitation that you need to consider when developing - this is context local objects. That's it, it introduces some complexity in the presence of a large codebase, tk. multiple objects defined in github.com/mitsuhiko/flask/blob/master/flask/globals.py, are global and need to be explicitly imported to use them, making it easy to shoot yourself in the foot. For high-load projects with a moderate amount of project code, I see no problems. A bunch of nginx + gunicorn + application can withstand normal loads even on the same machine. If the project is very large, then no one bothers to deploy several frontends and use a balancer.
Flask is just a small wrapper over Werkzeug in the form of a class that acts as a callable object for WSGI, glue for Jinja, an API for extensions, and a few goodies in the form of blueprints and signals. There is not much code and it is easy to read.

I
igrishaev, 2013-03-25
@igrishaev

Flask is a very good framework, convenient and understandable. Its main advantage and disadvantage at the same time is that Flask imposes much fewer restrictions on the developer compared to Django, for example. Therefore, you will have to think over the structure of packages and files on your own. But it's not so scary, understanding comes with the first project.
Large Flask projects can be broken down into component parts - Blueprints. This is an analogue of applications in Django. Blueprint can have its own address prefix, its own templates, forms, models. With the help of them, you can gradually increase the functionality of the project.
True, there is less documentation and ready-made solutions for Flask, but the main ones - SqlAlchemy for the database and WTForms for html forms - work very well, an order of magnitude better than the Dzhang counterparts.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question