Create an :class:`~flask.ctx.AppContext`. Use as a ``with`` block to push the context, which will make :data:`current_app` point at this application. An application context is automatically pushed by :meth:`RequestContext.push() <flask.ctx.RequestContext.push>`
(self)
| 1384 | appcontext_tearing_down.send(self, _async_wrapper=self.ensure_sync, exc=exc) |
| 1385 | |
| 1386 | def app_context(self) -> AppContext: |
| 1387 | """Create an :class:`~flask.ctx.AppContext`. Use as a ``with`` |
| 1388 | block to push the context, which will make :data:`current_app` |
| 1389 | point at this application. |
| 1390 | |
| 1391 | An application context is automatically pushed by |
| 1392 | :meth:`RequestContext.push() <flask.ctx.RequestContext.push>` |
| 1393 | when handling a request, and when running a CLI command. Use |
| 1394 | this to manually create a context outside of these situations. |
| 1395 | |
| 1396 | :: |
| 1397 | |
| 1398 | with app.app_context(): |
| 1399 | init_db() |
| 1400 | |
| 1401 | See :doc:`/appcontext`. |
| 1402 | |
| 1403 | .. versionadded:: 0.9 |
| 1404 | """ |
| 1405 | return AppContext(self) |
| 1406 | |
| 1407 | def request_context(self, environ: WSGIEnvironment) -> RequestContext: |
| 1408 | """Create a :class:`~flask.ctx.RequestContext` representing a |