Add command switch tabs for Bash, CMD and Powershell with sphinx-tabs (#3714)
* Enable Sphinx extension sphinx-tabs * Add command tabs for all export commands * Add command tabs for all venv commands Fix trim spaces
This commit is contained in:
parent
c5a5d9b30b
commit
1035efc7d6
14 changed files with 498 additions and 126 deletions
|
|
@ -87,16 +87,56 @@ For more information about the design of extensions refer to :doc:`/extensiondev
|
|||
Using Applications
|
||||
------------------
|
||||
|
||||
To run such an application, you can use the :command:`flask` command::
|
||||
To run such an application, you can use the :command:`flask` command:
|
||||
|
||||
$ export FLASK_APP=myapp
|
||||
$ flask run
|
||||
.. tabs::
|
||||
|
||||
.. group-tab:: Bash
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
$ export FLASK_APP=myapp
|
||||
$ flask run
|
||||
|
||||
.. group-tab:: CMD
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
> set FLASK_APP=myapp
|
||||
> flask run
|
||||
|
||||
.. group-tab:: Powershell
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
> $env:FLASK_APP = "myapp"
|
||||
> flask run
|
||||
|
||||
Flask will automatically detect the factory (``create_app`` or ``make_app``)
|
||||
in ``myapp``. You can also pass arguments to the factory like this::
|
||||
in ``myapp``. You can also pass arguments to the factory like this:
|
||||
|
||||
$ export FLASK_APP="myapp:create_app('dev')"
|
||||
$ flask run
|
||||
.. tabs::
|
||||
|
||||
.. group-tab:: Bash
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
$ export FLASK_APP="myapp:create_app('dev')"
|
||||
$ flask run
|
||||
|
||||
.. group-tab:: CMD
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
> set FLASK_APP="myapp:create_app('dev')"
|
||||
> flask run
|
||||
|
||||
.. group-tab:: Powershell
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
> $env:FLASK_APP = "myapp:create_app('dev')"
|
||||
> flask run
|
||||
|
||||
Then the ``create_app`` factory in ``myapp`` is called with the string
|
||||
``'dev'`` as the argument. See :doc:`/cli` for more detail.
|
||||
|
|
|
|||
|
|
@ -57,15 +57,51 @@ a big problem, just add a new file called :file:`setup.py` next to the inner
|
|||
)
|
||||
|
||||
In order to run the application you need to export an environment variable
|
||||
that tells Flask where to find the application instance::
|
||||
that tells Flask where to find the application instance:
|
||||
|
||||
$ export FLASK_APP=yourapplication
|
||||
.. tabs::
|
||||
|
||||
.. group-tab:: Bash
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
$ export FLASK_APP=yourapplication
|
||||
|
||||
.. group-tab:: CMD
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
> set FLASK_APP=yourapplication
|
||||
|
||||
.. group-tab:: Powershell
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
> $env:FLASK_APP = "yourapplication"
|
||||
|
||||
If you are outside of the project directory make sure to provide the exact
|
||||
path to your application directory. Similarly you can turn on the
|
||||
development features like this::
|
||||
development features like this:
|
||||
|
||||
$ export FLASK_ENV=development
|
||||
.. tabs::
|
||||
|
||||
.. group-tab:: Bash
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
$ export FLASK_ENV=development
|
||||
|
||||
.. group-tab:: CMD
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
> set FLASK_ENV=development
|
||||
|
||||
.. group-tab:: Powershell
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
> $env:FLASK_ENV = "development"
|
||||
|
||||
In order to install and run the application you need to issue the following
|
||||
commands::
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue