Made grammar changes to the Tutorial.

This commit is contained in:
Matthew Rankin 2010-12-30 09:00:56 -06:00
parent 8421c1ea0c
commit 86cc6f9806
10 changed files with 63 additions and 64 deletions

View file

@ -3,13 +3,12 @@
Step 2: Application Setup Code
==============================
Now that we have the schema in place we can create the application module.
Let's call it `flaskr.py` inside the `flaskr` folder. For starters we
will add the imports we will need as well as the config section. For
small applications it's a possibility to drop the configuration directly
into the module which we will be doing here. However a cleaner solution
would be to create a separate `.ini` or `.py` file and load that or import
the values from there.
Now that we have the schema in place, we can create the application module.
Let's call it `flaskr.py` inside the `flaskr` folder. For starters, we
will add the required imports as well as the config section. For
small applications, such as this, the configuration can be dropped directly
into the application module. However, a cleaner solution would be to create
a separate `.ini` or `.py` file and load that or import the values from there.
::
@ -34,12 +33,11 @@ config from the same file::
:meth:`~flask.Config.from_object` will look at the given object (if it's a
string it will import it) and then look for all uppercase variables
defined there. In our case, the configuration we just wrote a few lines
of code above. You can also move that into a separate file.
defined there. In our case, :meth:`~flask.Config.from_object` finds the
configuration we just wrote a few lines of code above.
It is also a good idea to be able to load a configuration from a
configurable file. This is what :meth:`~flask.Config.from_envvar` can
do::
configurable file. This is the purpose of :meth:`~flask.Config.from_envvar`::
app.config.from_envvar('FLASKR_SETTINGS', silent=True)
@ -63,16 +61,17 @@ Python shell or a script. This will come in handy later.
def connect_db():
return sqlite3.connect(app.config['DATABASE'])
Finally we just add a line to the bottom of the file that fires up the
Finally, we add a line to the bottom of the file that fires up the
server if we want to run that file as a standalone application::
if __name__ == '__main__':
app.run()
With that out of the way you should be able to start up the application
without problems. When you head over to the server you will get an 404
page not found error because we don't have any views yet. But we will
focus on that a little later. First we should get the database working.
With that out of the way you should be able to start up the application.
When you head over to your web browser you will get a 404
page not found error because we don't have any views yet. Not to worry,
we'll create some views in a bit. But first we should get the database
working.
.. admonition:: Externally Visible Server