Skip to content
Myr

Some documentation improvements

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

authored by Armin Ronacher · committed by Armin Ronacher · parent 60e143e · Browse files · 2 files+49 added−1 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+49 added−1 removed

  • other:+49 added−1 removed

2 files+49 added−1 removed

modified:docs/patterns/packages.rst+46 added
195 unmodified lines
196197 @frontend.route('/')198 def index():199 return "I'm the index"200201.. _modules-and-resources:202203Modules and Resources204---------------------205206.. versionadded:: 0.5207208If a module is located inside an actual Python package it may contain209static files and templates. Imagine you have an application like this::210211212 /yourapplication213 __init__.py214 /apps215 /frontend216 __init__.py217 views.py218 /static219 style.css220 /templates221 index.html222 about.html223 ...224 /admin225 __init__.py226 views.py227 /static228 style.css229 /templates230 list_items.html231 show_item.html232 ...233234The static folders automatically become exposed as URLs. For example if235the `admin` module is exported with an URL prefix of ``/admin`` you can236access the style css from its static folder by going to237``/admin/static/style.css``. The URL endpoint for the static files of the238admin would be ``'admin.static'``, similar to how you refer to the regular239static folder of the whole application as ``'static'``.240241If you want to refer to the templates you just have to prefix it with the242name of the module. So for the admin it would be243``render_template('admin/list_items.html')`` and so on. It is not244possible to refer to templates without the prefixed modlue name. This is245explicit unlike URL rules.
modified:flask/module.py+3 added-1 removed
88 unmodified lines
89 For a gentle introduction into modules, checkout the90 :ref:`working-with-modules` section.9192 .. versionadded:: 0.593 The `static_path` parameter was added.93 The `static_path` parameter was added and it's now possible for94 modules to refer to their own templates and static files. See95 :ref:`modules-and-resources` for more information.9697 :param import_name: the name of the Python package or module98 implementing this :class:`Module`.99 :param name: the internal short name for the module. Unless specified
105 unmodified lines