Skip to content
Myr

Copy edited and partially rewrote the foreword.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Matt Campbell · committed by Armin Ronacher · parent 14fde07 · Browse files · 2 files+52 added−52 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+52 added−52 removed

  • other:+52 added−52 removed

2 files+52 added−52 removed

modified:docs/contents.rst.inc+3 added-3 removed
1User's Guide2------------34This part of the documentation is written text and should give you an idea5how to work with Flask. It's a series of step-by-step instructions for6web development.4This part of the documentation, which is mostly prose, begins with some5background information about Flask, then focuses on step-by-step6instructions for web development with Flask.78.. toctree::9 :maxdepth: 210
39 unmodified lines
modified:docs/foreword.rst+49 added-49 removed
1Foreword2========34Read this before you get started with Flask. This hopefully answers some5questions about the intention of the project, what it aims at and when you5questions about the purpose and goals of the project, and when you6should or should not be using it.78What does Micro Mean?9---------------------8What does "micro" mean?9-----------------------1011The micro in microframework for me means on the one hand being small in12size and complexity but on the other hand also that the complexity of the13applications that are written with these frameworks do not exceed a14certain size. A microframework like Flask sacrifices a few things in15order to be approachable and to be as concise as possible.11To me, the "micro" in microframework refers not only to the simplicity and12small size of the framework, but also to the typically limited complexity13and size of applications that are written with the framework. To be14approachable and concise, a microframework sacrifices a few features that15may be necessary in larger or more complex applications.1617For example Flask uses thread local objects internally so that you don't17For example, Flask uses thread-local objects internally so that you don't18have to pass objects around from function to function within a request in19order to stay threadsafe. While this is a really easy approach and saves20you a lot of time, it also does not scale well to large applications.21It's especially painful for more complex unittests and when you suddenly22have to deal with code being executed outside of the context of a request23(for example if you have cronjobs).21It's especially painful for more complex unittests, and when you suddenly22have to deal with code being executed outside of the context of a request,23such as in cron jobs.2425Flask provides some tools to deal with the downsides of this approach but26the core problem of this approach obviously stays. It is also based on27convention over configuration which means that a lot of things are28preconfigured in Flask and will work well for smaller applications but not29so much for larger ones (where and how it looks for templates, static30files etc.)25Flask provides some tools to deal with the downsides of this approach, but26the core problem remains. Flask is also based on convention over27configuration, which means that many things are preconfigured and will28work well for smaller applications but not so well for larger ones. For29example, by convention, templates and static files are in subdirectories30within the Python source tree of the application.3132But don't worry if your application suddenly grows larger than it was33initially and you're afraid Flask might not grow with it. Even with34larger frameworks you sooner or later will find out that you need32But don't worry if your application suddenly grows larger33and you're afraid Flask might not grow with it. Even with34larger frameworks, you'll eventually discover that you need35something the framework just cannot do for you without modification.36If you are ever in that situation, check out the :ref:`becomingbig`37chapter.3839A Framework and An Example39A Framework and an Example40--------------------------4142Flask is not only a microframework, it is also an example. Based on42Flask is not only a microframework; it is also an example. Based on43Flask, there will be a series of blog posts that explain how to create a44framework. Flask itself is just one way to implement a framework on top45of existing libraries. Unlike many other microframeworks Flask does not46try to implement anything on its own, it reuses existing code.45of existing libraries. Unlike many other microframeworks, Flask does not46try to implement everything on its own; it reuses existing code.4748Web Development is Dangerous49----------------------------5051I'm not even joking. Well, maybe a little. If you write a web52application you are probably allowing users to register and leave their51I'm not joking. Well, maybe a little. If you write a web52application, you are probably allowing users to register and leave their53data on your server. The users are entrusting you with data. And even if54you are the only user that might leave data in your application, you still55want that data to be stored in a secure manner.55want that data to be stored securely.5657Unfortunately there are many ways security of a web application can be57Unfortunately, there are many ways the security of a web application can be58compromised. Flask protects you against one of the most common security59problems of modern web applications: cross site scripting (XSS). Unless60you deliberately mark insecure HTML as secure Flask (and the underlying61Jinja2 template engine) have you covered. But there are many more ways to59problems of modern web applications: cross-site scripting (XSS). Unless60you deliberately mark insecure HTML as secure, Flask and the underlying61Jinja2 template engine have you covered. But there are many more ways to62cause security problems.6364Whenever something is dangerous where you have to watch out, the65documentation will tell you so. Some of the security concerns of web66development are far more complex than one might think and often we all end67up in situations where we think "well, this is just far fetched, how could68that possibly be exploited" and then an intelligent guy comes along and69figures a way out to exploit that application. And don't think, your70application is not important enough for hackers to take notice. Depending71on the kind of attack, chances are there are automated botnets out there72trying to figure out how to fill your database with viagra advertisements.64The documentation will warn you about aspects of web development that65require attention to security. Some of these security concerns66are far more complex than one might think, and we all sometimes underestimate67the likelihood that a vulnerability will be exploited, until a clever68attacker figures out a way to exploit our applications. And don't think69that your application is not important enough to attract an attacker.70Depending on the kind of attack, chances are that automated bots are71probing for ways to fill your database with spam, links to malicious72software, and the like.7374So always keep that in mind when doing web development.74So always keep security in mind when doing web development.7576Target Audience77---------------7879Is Flask for you? If your application small-ish and does not depend on80too complex database structures, Flask is the Framework for you. It was81designed from the ground up to be easy to use, based on established82principles, good intentions and on top of two established libraries in83widespread usage. Recent versions of Flask scale nicely within reasonable84bounds and if you grow larger, you won't have any troubles adjusting Flask79Is Flask for you? If your application is small-ish and does not depend on80very complex database structures, Flask is the Framework for you. It was81designed from the ground up to be easy to use, and built on the firm82foundation of established principles, good intentions, and mature, widely83used libraries. Recent versions of Flask scale nicely within reasonable84bounds, and if you grow larger, you won't have any trouble adjusting Flask85for your new application size.8687If you suddenly discover that your application grows larger than88originally intended, head over to the :ref:`becomingbig` section to see89some possible solutions for larger applications.9091Satisfied? Then head over to the :ref:`installation`.91Satisfied? Then let's proceed with :ref:`installation`.