Skip to content
Myr

foreword.rst

This file

Path

docs/foreword.rst

100 lines · 5.1 KiB

Last changed by

Merge pull request #369 from FND/docsArmin Ronacherbefore adoptionf64098c

History of this file

Take it

The walk stopped after 200 commits: lines older than de3b6ab point at it.

Fixed a broken sentence about blueprints.Armin Ronacherbefore adoptionde3b6ab

lines 1–11why, one step back
1Foreword
2========34Read this before you get started with Flask. This hopefully answers some5questions about the purpose and goals of the project, and when you6should or should not be using it.78What does "micro" mean?9-----------------------1011To me, the "micro" in microframework refers not only to the simplicity and

Merge pull request #369 from FND/docsArmin Ronacherbefore adoptionf64098c

line 12why, one step back
12small size of the framework, but also the fact that it does not make many

Made the foreword less defensive.Armin Ronacherbefore adoptiondc05722

lines 13–14why, one step back
13decisions for you. While Flask does pick a templating engine for you, we
14won't make such decisions for your datastore or other parts.

Fixed a broken sentence about blueprints.Armin Ronacherbefore adoptionde3b6ab

line 15why, one step back
15

Merge pull request #369 from FND/docsArmin Ronacherbefore adoptionf64098c

line 16why, one step back
16However, to us the term “micro” does not mean that the whole implementation

Made the foreword less defensive.Armin Ronacherbefore adoptiondc05722

line 17why, one step back
17has to fit into a single Python file.

Fixed a broken sentence about blueprints.Armin Ronacherbefore adoptionde3b6ab

line 18why, one step back
18

Made the foreword less defensive.Armin Ronacherbefore adoptiondc05722

line 19why, one step back
19One of the design decisions with Flask was that simple tasks should be

Merge pull request #369 from FND/docsArmin Ronacherbefore adoptionf64098c

lines 20–21why, one step back
20simple; they should not take a lot of code and yet they should not limit you.
21Because of that we made a few design choices that some people might find

Made the foreword less defensive.Armin Ronacherbefore adoptiondc05722

lines 22–30why, one step back
22surprising or unorthodox. For example, Flask uses thread-local objects
23internally so that you don't have to pass objects around from function to24function within a request in order to stay threadsafe. While this is a25really easy approach and saves you a lot of time, it might also cause some26troubles for very large applications because changes on these thread-local27objects can happen anywhere in the same thread. In order to solve these28problems we don't hide the thread locals for you but instead embrace them29and provide you with a lot of tools to make it as pleasant as possible to30work with them.

Fixed a broken sentence about blueprints.Armin Ronacherbefore adoptionde3b6ab

lines 31–32why, one step back
31
32Flask is also based on convention over configuration, which means that

Merge pull request #369 from FND/docsArmin Ronacherbefore adoptionf64098c

lines 33–35why, one step back
33many things are preconfigured. For example, by convention templates and
34static files are stored in subdirectories within the application's Python source tree.35While this can be changed you usually don't have to.

Fixed a broken sentence about blueprints.Armin Ronacherbefore adoptionde3b6ab

line 36why, one step back
36

Merge pull request #369 from FND/docsArmin Ronacherbefore adoptionf64098c

line 37why, one step back
37The main reason Flask is called a "microframework" is the idea

Fixed a broken sentence about blueprints.Armin Ronacherbefore adoptionde3b6ab

lines 38–39why, one step back
38to keep the core simple but extensible. There is no database abstraction
39layer, no form validation or anything else where different libraries

Merge pull request #369 from FND/docsArmin Ronacherbefore adoptionf64098c

lines 40–41why, one step back
40already exist that can handle that. However Flask supports
41extensions to add such functionality to your application as if it

Fixed a broken sentence about blueprints.Armin Ronacherbefore adoptionde3b6ab

line 42why, one step back
42was implemented in Flask itself. There are currently extensions for

Merge pull request #369 from FND/docsArmin Ronacherbefore adoptionf64098c

line 43why, one step back
43object-relational mappers, form validation, upload handling, various open

Fixed a broken sentence about blueprints.Armin Ronacherbefore adoptionde3b6ab

lines 44–45why, one step back
44authentication technologies and more.
45

Made the foreword less defensive.Armin Ronacherbefore adoptiondc05722

line 46why, one step back
46Since Flask is based on a very solid foundation there is not a lot of code

Simple documentation corrections, mostly typos.Craig Dennisbefore adoption75050d4

line 47why, one step back
47in Flask itself. As such it's easy to adapt even for large applications

Made the foreword less defensive.Armin Ronacherbefore adoptiondc05722

lines 48–50why, one step back
48and we are making sure that you can either configure it as much as
49possible by subclassing things or by forking the entire codebase. If you50are interested in that, check out the :ref:`becomingbig` chapter.

Fixed a broken sentence about blueprints.Armin Ronacherbefore adoptionde3b6ab

lines 51–73why, one step back
51
52If you are curious about the Flask design principles, head over to the53section about :ref:`design`.5455Web Development is Dangerous56----------------------------5758I'm not joking. Well, maybe a little. If you write a web59application, you are probably allowing users to register and leave their60data on your server. The users are entrusting you with data. And even if61you are the only user that might leave data in your application, you still62want that data to be stored securely.6364Unfortunately, there are many ways the security of a web application can be65compromised. Flask protects you against one of the most common security66problems of modern web applications: cross-site scripting (XSS). Unless67you deliberately mark insecure HTML as secure, Flask and the underlying68Jinja2 template engine have you covered. But there are many more ways to69cause security problems.7071The documentation will warn you about aspects of web development that72require attention to security. Some of these security concerns73are far more complex than one might think, and we all sometimes underestimate

Merge pull request #369 from FND/docsArmin Ronacherbefore adoptionf64098c

line 74why, one step back
74the likelihood that a vulnerability will be exploited - until a clever

Fixed a broken sentence about blueprints.Armin Ronacherbefore adoptionde3b6ab

lines 75–90why, one step back
75attacker figures out a way to exploit our applications. And don't think
76that your application is not important enough to attract an attacker.77Depending on the kind of attack, chances are that automated bots are78probing for ways to fill your database with spam, links to malicious79software, and the like.8081So always keep security in mind when doing web development.8283The Status of Python 384----------------------8586Currently the Python community is in the process of improving libraries to87support the new iteration of the Python programming language. While the88situation is greatly improving there are still some issues that make it89hard for us to switch over to Python 3 just now. These problems are90partially caused by changes in the language that went unreviewed for too

Merge pull request #369 from FND/docsArmin Ronacherbefore adoptionf64098c

lines 91–92why, one step back
91long, partially also because we have not quite worked out how the lower-
92level API should change to account for the Unicode differences in Python 3.

Fixed a broken sentence about blueprints.Armin Ronacherbefore adoptionde3b6ab

lines 93–100why, one step back
93
94Werkzeug and Flask will be ported to Python 3 as soon as a solution for95the changes is found, and we will provide helpful tips how to upgrade96existing applications to Python 3. Until then, we strongly recommend97using Python 2.6 and 2.7 with activated Python 3 warnings during98development. If you plan on upgrading to Python 3 in the near future we99strongly recommend that you read `How to write forwards compatible100Python code <http://lucumr.pocoo.org/2011/1/22/forwards-compatible-python/>`_.