docs: :file:app.py, :file:yourapp/templates

This commit is contained in:
defuz 2014-11-05 06:45:22 +03:00
parent 3fa4fd0908
commit a8f570cc62
32 changed files with 93 additions and 93 deletions

View file

@ -4,7 +4,7 @@ Step 7: Adding Style
====================
Now that everything else works, it's time to add some style to the
application. Just create a stylesheet called `style.css` in the `static`
application. Just create a stylesheet called :file:`style.css` in the :file:`static`
folder we created before:
.. sourcecode:: css

View file

@ -22,7 +22,7 @@ for you to the application.
To do this we can create a function and hook it into the ``flask`` command
that initializes the database. Let me show you the code first. Just add
this function below the `connect_db` function in `flaskr.py`::
this function below the `connect_db` function in :file:`flaskr.py`::
def init_db():
db = get_db()

View file

@ -13,9 +13,9 @@ application::
The `flaskr` folder is not a python package, but just something where we
drop our files. We will then put our database schema as well as main module
into this folder. It is done in the following way. The files inside
the `static` folder are available to users of the application via HTTP.
the :file:`static` folder are available to users of the application via HTTP.
This is the place where css and javascript files go. Inside the
`templates` folder Flask will look for `Jinja2`_ templates. The
:file:`templates` folder Flask will look for `Jinja2`_ templates. The
templates you create later in the tutorial will go in this directory.
Continue with :ref:`tutorial-schema`.

View file

@ -11,7 +11,7 @@ directly into the module, and this is what 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.
First we add the imports in `flaskr.py`::
First we add the imports in :file:`flaskr.py`::
# all the imports
import os
@ -20,7 +20,7 @@ First we add the imports in `flaskr.py`::
render_template, flash
Next we can create our actual application and initialize it with the
config from the same file, in `flaskr.py`::
config from the same file, in :file:`flaskr.py`::
# create our little application :)
app = Flask(__name__)
@ -54,14 +54,14 @@ can update it with new values.
:ref:`instance-folders` instead.
Usually, it is a good idea to load a separate, environment specific
configuration file. Flask allows you to import multiple configurations and it
will use the setting defined in the last import. This enables robust
configuration setups. :meth:`~flask.Config.from_envvar` can help achieve this.
configuration file. Flask allows you to import multiple configurations and it
will use the setting defined in the last import. This enables robust
configuration setups. :meth:`~flask.Config.from_envvar` can help achieve this.
app.config.from_envvar('FLASKR_SETTINGS', silent=True)
Simply define the environment variable :envvar:`FLASKR_SETTINGS` that points to
a config file to be loaded. The silent switch just tells Flask to not complain
Simply define the environment variable :envvar:`FLASKR_SETTINGS` that points to
a config file to be loaded. The silent switch just tells Flask to not complain
if no such environment key is set.
In addition to that you can use the :meth:`~flask.Config.from_object`

View file

@ -14,7 +14,7 @@ escaped with their XML equivalents.
We are also using template inheritance which makes it possible to reuse
the layout of the website in all pages.
Put the following templates into the `templates` folder:
Put the following templates into the :file:`templates` folder:
.. _Jinja2: http://jinja.pocoo.org/docs/templates
@ -55,7 +55,7 @@ the session:
show_entries.html
-----------------
This template extends the `layout.html` template from above to display the
This template extends the :file:`layout.html` template from above to display the
messages. Note that the `for` loop iterates over the messages we passed
in with the :func:`~flask.render_template` function. We also tell the
form to submit to your `add_entry` function and use ``POST`` as HTTP

View file

@ -16,7 +16,7 @@ returned from the cursor look a bit like tuples because we are using
the :class:`sqlite3.Row` row factory.
The view function will pass the entries as dicts to the
`show_entries.html` template and return the rendered one::
:file:`show_entries.html` template and return the rendered one::
@app.route('/')
def show_entries():