Skip to content
Myr

Fixed some minor typos throughout docs.

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

authored by Ron DuPlain · committed by Armin Ronacher · parent e409bc7 · Browse files · 5 files+17 added−17 removed
This commit

State

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

Diff stats

5 files+17 added−17 removed

  • other:+17 added−17 removed

5 files+17 added−17 removed

modified:docs/becomingbig.rst+2 added-2 removed
23 unmodified lines
24In that case, it makes a lot of sense to use dotted names for the URL25endpoints.2627Here are some suggestions for how Flask can be modified to better 28accomodate large-scale applications:28accommodate large-scale applications:2930- implement dotted names for URL endpoints31- get rid of the decorator function registering which causes a lot32 of troubles for applications that have circular dependencies. It33 also requires that the whole application is imported when the system34 initializes or certain URLs will not be available right away. A35 better solution would be to have one module with all URLs in there and36 specifing the target functions explicitly or by name and importing36 specifying the target functions explicitly or by name and importing37 them when needed.38- switch to explicit request object passing. This requires more typing39 (because you now have something to pass around) but it makes it a40 whole lot easier to debug hairy situations and to test the code.
17 unmodified lines
modified:docs/design.rst+3 added-3 removed
49 unmodified lines
50possible without hacks if the object were created ahead of time for you51based on a class that is not exposed to you.5253But there is another very important reason why Flask depends on an54explicit instanciation of that class: the package name. Whenever you54explicit instantiation of that class: the package name. Whenever you55create a Flask instance you usually pass it `__name__` as package name.56Flask depends on that information to properly load resources relative57to your module. With Python's outstanding support for reflection it can58then access the package to figure out where the templates and static files
65 unmodified lines
124125Flask is a framework that takes advantage of the work already done by126Werkzeug to properly interface WSGI (which can be a complex task at127times). Thanks to recent developments in the Python package128infrastructure, packages with depencencies are no longer an issue and128infrastructure, packages with dependencies are no longer an issue and129there are very few reasons against having libraries that depend on others.130131132Thread Locals
6 unmodified lines
139140Yes it is usually not such a bright idea to use thread locals. They cause141troubles for servers that are not based on the concept of threads and make142large applications harder to maintain. However Flask is just not designed143for large applications or asyncronous servers. Flask wants to make it143for large applications or asynchronous servers. Flask wants to make it144quick and easy to write a traditional web application.145146Also see the :ref:`becomingbig` section of the documentation for some147inspiration for larger applications based on Flask.
modified:docs/foreword.rst+3 added-3 removed
66 unmodified lines
67up 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. Depending71ont he kind of attack, chances are there are automated botnets out there72trying to figure out how to fill your database with viagra adverisments.71on the kind of attack, chances are there are automated botnets out there72trying to figure out how to fill your database with viagra advertisements.7374So always keep that in mind when doing web development.7576Target Audience77---------------7879Is Flask for you? Is your application small-ish (less than 4000 lines of79Is Flask for you? If your application small-ish (less than 4000 lines of80Python code) and does not depend on too complex database structures, Flask81is the Framework for you. It was designed from the ground up to be easy82to use, based on established principles, good intentions and on top of two83established libraries in widespread usage.
11 unmodified lines
modified:docs/installation.rst+1 added-1 removed
120 unmodified lines
121 $ python setup.py develop122 ...123 Finished processing dependencies for Flask124125This will pull in the depdenencies and activate the git head as current125This will pull in the dependencies and activate the git head as current126version. Then you just have to ``git pull origin`` to get the latest127version.128129To just get the development version without git, do this instead::
44 unmodified lines
modified:docs/quickstart.rst+8 added-8 removed
81 unmodified lines
82you enable the debug support the server will reload itself on code changes83and also provide you with a helpful debugger if things go wrong.8485There are two ways to enable debugging. Either set that flag on the86applciation object::86application object::8788 app.debug = True89 app.run()90
47 unmodified lines
138likely he will like the page and come back next time.139140To add variable parts to a URL you can mark these special sections as141``<variable_name>``. Such a part is then passed as keyword argument to142your function. Optionally a converter can be specifed by specifying a142your function. Optionally a converter can be specified by specifying a143rule with ``<converter:variable_name>``. Here some nice examples::144145 @app.route('/user/<username>')146 def show_user_profile(username):
38 unmodified lines
185... 186>>> with app.test_request_context():187... print url_for('index')188... print url_for('login')189... print url_for('profile', username='John Doe')189... print url_for('login', next='/')190... print url_for('profile', username='John Doe')191... 192/193/login194/login?next=/
123 unmodified lines
318 return render_template('hello.html', name=name)319320Flask will look for templates in the `templates` folder. So if your321application is a module, that folder is next to that module, if it's a322pacakge it's actually inside your package:322package it's actually inside your package:323324**Case 1**: a module::325 326 /application.py
156 unmodified lines
483We recommend accessing URL parameters with `get` or by catching the484`KeyError` because users might change the URL and presenting them a 400485bad request page in that case is a bit user unfriendly.486487For a full list of methods and attribtues on that object, head over to the487For a full list of methods and attributes on that object, head over to the488:class:`~flask.request` documentation.489490491File Uploads492````````````493494Obviously you can handle uploaded files with Flask just as easy. Just495make sure not to forget to set the ``enctype="multipart/form-data"``496attribtue on your HTML form, otherwise the browser will not transmit your496attribute on your HTML form, otherwise the browser will not transmit your497files at all.498499Uploaded files are stored in memory or at a temporary location on the500filesystem. You can access those files by looking at the
74 unmodified lines
575 return render_template('page_not_found.html'), 404576577Note the ``404`` after the :func:`~flask.render_template` call. This578tells Flask that the status code of that page should be 404 which means579not found. By default 200 is assumed which translats to: all went well.579not found. By default 200 is assumed which translates to: all went well.580581.. _sessions:582583Sessions
1 unmodified line
585586Besides the request object there is also a second object called587:class:`~flask.session` that allows you to store information specific to a588user from one request to the next. This is implemented on top of cookies589for you and signes the cookies cryptographically. What this means is that589for you and signs the cookies cryptographically. What this means is that590the user could look at the contents of your cookie but not modify it,591unless he knows the secret key used for signing.592593In order to use sessions you have to set a secret key. Here is how
48 unmodified lines