advanced_foreword.rst
This file
Path
docs/advanced_foreword.rst
48 lines · 2.4 KiB
Last changed by
Merge pull request #3175 from singingwolfboy/fix-rst-line-too-longDavid Baumgoldbefore adoption819368a
History of this fileTake it
The walk stopped after 200 commits: lines older than c74f469 point at it.
Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
lines 1–10why, one step back1.. _advanced_foreword:23Foreword for Experienced Programmers4====================================56Thread-Locals in Flask7----------------------89One of the design decisions in Flask was that simple tasks should be simple;10they should not take a lot of code and yet they should not limit you. BecauseMerge pull request #3175 from singingwolfboy/fix-rst-line-too-longDavid Baumgoldbefore adoption819368a
lines 11–15why, one step back11of that, Flask has a few design choices that some people might find12surprising or unorthodox. For example, Flask uses thread-local objects13internally so that you don’t have to pass objects around from14function to function within a request in order to stay threadsafe.15This approach is convenient, but requires a validMerge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
lines 16–48why, one step back16request context for dependency injection or when attempting to reuse code which17uses a value pegged to the request. The Flask project is honest about18thread-locals, does not hide them, and calls out in the code and documentation19where they are used.2021Develop for the Web with Caution22--------------------------------2324Always keep security in mind when building web applications.2526If you write a web application, you are probably allowing users to register27and leave their data on your server. The users are entrusting you with data.28And even if you are the only user that might leave data in your application,29you still want that data to be stored securely.3031Unfortunately, there are many ways the security of a web application can be32compromised. Flask protects you against one of the most common security33problems of modern web applications: cross-site scripting (XSS). Unless you34deliberately mark insecure HTML as secure, Flask and the underlying Jinja235template engine have you covered. But there are many more ways to cause36security problems.3738The documentation will warn you about aspects of web development that require39attention to security. Some of these security concerns are far more complex40than one might think, and we all sometimes underestimate the likelihood that a41vulnerability will be exploited - until a clever attacker figures out a way to42exploit our applications. And don't think that your application is not43important enough to attract an attacker. Depending on the kind of attack,44chances are that automated bots are probing for ways to fill your database with45spam, links to malicious software, and the like.4647Flask is no different from any other framework in that you the developer must48build with caution, watching for exploits when building to your requirements.