forked from orbit-oss/flask
Fixed some minor typos throughout docs.
This commit is contained in:
parent
e409bc792d
commit
93a8ca0282
5 changed files with 17 additions and 17 deletions
|
|
@ -25,7 +25,7 @@ In that case, it makes a lot of sense to use dotted names for the URL
|
||||||
endpoints.
|
endpoints.
|
||||||
|
|
||||||
Here are some suggestions for how Flask can be modified to better
|
Here are some suggestions for how Flask can be modified to better
|
||||||
accomodate large-scale applications:
|
accommodate large-scale applications:
|
||||||
|
|
||||||
- implement dotted names for URL endpoints
|
- implement dotted names for URL endpoints
|
||||||
- get rid of the decorator function registering which causes a lot
|
- get rid of the decorator function registering which causes a lot
|
||||||
|
|
@ -33,7 +33,7 @@ accomodate large-scale applications:
|
||||||
also requires that the whole application is imported when the system
|
also requires that the whole application is imported when the system
|
||||||
initializes or certain URLs will not be available right away. A
|
initializes or certain URLs will not be available right away. A
|
||||||
better solution would be to have one module with all URLs in there and
|
better solution would be to have one module with all URLs in there and
|
||||||
specifing the target functions explicitly or by name and importing
|
specifying the target functions explicitly or by name and importing
|
||||||
them when needed.
|
them when needed.
|
||||||
- switch to explicit request object passing. This requires more typing
|
- switch to explicit request object passing. This requires more typing
|
||||||
(because you now have something to pass around) but it makes it a
|
(because you now have something to pass around) but it makes it a
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ possible without hacks if the object were created ahead of time for you
|
||||||
based on a class that is not exposed to you.
|
based on a class that is not exposed to you.
|
||||||
|
|
||||||
But there is another very important reason why Flask depends on an
|
But there is another very important reason why Flask depends on an
|
||||||
explicit instanciation of that class: the package name. Whenever you
|
explicit instantiation of that class: the package name. Whenever you
|
||||||
create a Flask instance you usually pass it `__name__` as package name.
|
create a Flask instance you usually pass it `__name__` as package name.
|
||||||
Flask depends on that information to properly load resources relative
|
Flask depends on that information to properly load resources relative
|
||||||
to your module. With Python's outstanding support for reflection it can
|
to your module. With Python's outstanding support for reflection it can
|
||||||
|
|
@ -125,7 +125,7 @@ advantage.
|
||||||
Flask is a framework that takes advantage of the work already done by
|
Flask is a framework that takes advantage of the work already done by
|
||||||
Werkzeug to properly interface WSGI (which can be a complex task at
|
Werkzeug to properly interface WSGI (which can be a complex task at
|
||||||
times). Thanks to recent developments in the Python package
|
times). Thanks to recent developments in the Python package
|
||||||
infrastructure, packages with depencencies are no longer an issue and
|
infrastructure, packages with dependencies are no longer an issue and
|
||||||
there are very few reasons against having libraries that depend on others.
|
there are very few reasons against having libraries that depend on others.
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -140,7 +140,7 @@ isn't that a bad idea?
|
||||||
Yes it is usually not such a bright idea to use thread locals. They cause
|
Yes it is usually not such a bright idea to use thread locals. They cause
|
||||||
troubles for servers that are not based on the concept of threads and make
|
troubles for servers that are not based on the concept of threads and make
|
||||||
large applications harder to maintain. However Flask is just not designed
|
large applications harder to maintain. However Flask is just not designed
|
||||||
for large applications or asyncronous servers. Flask wants to make it
|
for large applications or asynchronous servers. Flask wants to make it
|
||||||
quick and easy to write a traditional web application.
|
quick and easy to write a traditional web application.
|
||||||
|
|
||||||
Also see the :ref:`becomingbig` section of the documentation for some
|
Also see the :ref:`becomingbig` section of the documentation for some
|
||||||
|
|
|
||||||
|
|
@ -68,15 +68,15 @@ up in situations where we think "well, this is just far fetched, how could
|
||||||
that possibly be exploited" and then an intelligent guy comes along and
|
that possibly be exploited" and then an intelligent guy comes along and
|
||||||
figures a way out to exploit that application. And don't think, your
|
figures a way out to exploit that application. And don't think, your
|
||||||
application is not important enough for hackers to take notice. Depending
|
application is not important enough for hackers to take notice. Depending
|
||||||
ont he kind of attack, chances are there are automated botnets out there
|
on the kind of attack, chances are there are automated botnets out there
|
||||||
trying to figure out how to fill your database with viagra adverisments.
|
trying to figure out how to fill your database with viagra advertisements.
|
||||||
|
|
||||||
So always keep that in mind when doing web development.
|
So always keep that in mind when doing web development.
|
||||||
|
|
||||||
Target Audience
|
Target Audience
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
Is Flask for you? Is your application small-ish (less than 4000 lines of
|
Is Flask for you? If your application small-ish (less than 4000 lines of
|
||||||
Python code) and does not depend on too complex database structures, Flask
|
Python code) and does not depend on too complex database structures, Flask
|
||||||
is the Framework for you. It was designed from the ground up to be easy
|
is the Framework for you. It was designed from the ground up to be easy
|
||||||
to use, based on established principles, good intentions and on top of two
|
to use, based on established principles, good intentions and on top of two
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ Get the git checkout in a new virtualenv and run in develop mode::
|
||||||
...
|
...
|
||||||
Finished processing dependencies for Flask
|
Finished processing dependencies for Flask
|
||||||
|
|
||||||
This will pull in the depdenencies and activate the git head as current
|
This will pull in the dependencies and activate the git head as current
|
||||||
version. Then you just have to ``git pull origin`` to get the latest
|
version. Then you just have to ``git pull origin`` to get the latest
|
||||||
version.
|
version.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ you enable the debug support the server will reload itself on code changes
|
||||||
and also provide you with a helpful debugger if things go wrong.
|
and also provide you with a helpful debugger if things go wrong.
|
||||||
|
|
||||||
There are two ways to enable debugging. Either set that flag on the
|
There are two ways to enable debugging. Either set that flag on the
|
||||||
applciation object::
|
application object::
|
||||||
|
|
||||||
app.debug = True
|
app.debug = True
|
||||||
app.run()
|
app.run()
|
||||||
|
|
@ -139,7 +139,7 @@ likely he will like the page and come back next time.
|
||||||
|
|
||||||
To add variable parts to a URL you can mark these special sections as
|
To add variable parts to a URL you can mark these special sections as
|
||||||
``<variable_name>``. Such a part is then passed as keyword argument to
|
``<variable_name>``. Such a part is then passed as keyword argument to
|
||||||
your function. Optionally a converter can be specifed by specifying a
|
your function. Optionally a converter can be specified by specifying a
|
||||||
rule with ``<converter:variable_name>``. Here some nice examples::
|
rule with ``<converter:variable_name>``. Here some nice examples::
|
||||||
|
|
||||||
@app.route('/user/<username>')
|
@app.route('/user/<username>')
|
||||||
|
|
@ -186,8 +186,8 @@ parameter. Here some examples:
|
||||||
>>> with app.test_request_context():
|
>>> with app.test_request_context():
|
||||||
... print url_for('index')
|
... print url_for('index')
|
||||||
... print url_for('login')
|
... print url_for('login')
|
||||||
... print url_for('profile', username='John Doe')
|
|
||||||
... print url_for('login', next='/')
|
... print url_for('login', next='/')
|
||||||
|
... print url_for('profile', username='John Doe')
|
||||||
...
|
...
|
||||||
/
|
/
|
||||||
/login
|
/login
|
||||||
|
|
@ -319,7 +319,7 @@ Here's a simple example of how to render a template::
|
||||||
|
|
||||||
Flask will look for templates in the `templates` folder. So if your
|
Flask will look for templates in the `templates` folder. So if your
|
||||||
application is a module, that folder is next to that module, if it's a
|
application is a module, that folder is next to that module, if it's a
|
||||||
pacakge it's actually inside your package:
|
package it's actually inside your package:
|
||||||
|
|
||||||
**Case 1**: a module::
|
**Case 1**: a module::
|
||||||
|
|
||||||
|
|
@ -484,7 +484,7 @@ We recommend accessing URL parameters with `get` or by catching the
|
||||||
`KeyError` because users might change the URL and presenting them a 400
|
`KeyError` because users might change the URL and presenting them a 400
|
||||||
bad request page in that case is a bit user unfriendly.
|
bad request page in that case is a bit user unfriendly.
|
||||||
|
|
||||||
For a full list of methods and attribtues on that object, head over to the
|
For a full list of methods and attributes on that object, head over to the
|
||||||
:class:`~flask.request` documentation.
|
:class:`~flask.request` documentation.
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -493,7 +493,7 @@ File Uploads
|
||||||
|
|
||||||
Obviously you can handle uploaded files with Flask just as easy. Just
|
Obviously you can handle uploaded files with Flask just as easy. Just
|
||||||
make sure not to forget to set the ``enctype="multipart/form-data"``
|
make sure not to forget to set the ``enctype="multipart/form-data"``
|
||||||
attribtue on your HTML form, otherwise the browser will not transmit your
|
attribute on your HTML form, otherwise the browser will not transmit your
|
||||||
files at all.
|
files at all.
|
||||||
|
|
||||||
Uploaded files are stored in memory or at a temporary location on the
|
Uploaded files are stored in memory or at a temporary location on the
|
||||||
|
|
@ -576,7 +576,7 @@ you want to customize the error page, you can use the
|
||||||
|
|
||||||
Note the ``404`` after the :func:`~flask.render_template` call. This
|
Note the ``404`` after the :func:`~flask.render_template` call. This
|
||||||
tells Flask that the status code of that page should be 404 which means
|
tells Flask that the status code of that page should be 404 which means
|
||||||
not found. By default 200 is assumed which translats to: all went well.
|
not found. By default 200 is assumed which translates to: all went well.
|
||||||
|
|
||||||
.. _sessions:
|
.. _sessions:
|
||||||
|
|
||||||
|
|
@ -586,7 +586,7 @@ Sessions
|
||||||
Besides the request object there is also a second object called
|
Besides the request object there is also a second object called
|
||||||
:class:`~flask.session` that allows you to store information specific to a
|
:class:`~flask.session` that allows you to store information specific to a
|
||||||
user from one request to the next. This is implemented on top of cookies
|
user from one request to the next. This is implemented on top of cookies
|
||||||
for you and signes the cookies cryptographically. What this means is that
|
for you and signs the cookies cryptographically. What this means is that
|
||||||
the user could look at the contents of your cookie but not modify it,
|
the user could look at the contents of your cookie but not modify it,
|
||||||
unless he knows the secret key used for signing.
|
unless he knows the secret key used for signing.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue