Skip to content
Myr

cli.rst

This file

Path

docs/cli.rst

571 lines · 16.6 KiB

Last changed by

Merge pull request #4980 from pallets/release-2.2.3David Lordbefore adoption6a392af

History of this file

Take it

The walk stopped after 200 commits: lines older than 4240ace point at it.

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

lines 1–17why, one step back
1.. currentmodule:: flask
23Command Line Interface4======================56Installing Flask installs the ``flask`` script, a `Click`_ command line7interface, in your virtualenv. Executed from the terminal, this script gives8access to built-in, extension, and application-defined commands. The ``--help``9option will give more information about any commands and options.1011.. _Click: https://click.palletsprojects.com/121314Application Discovery15---------------------1617The ``flask`` command is installed by Flask, not your application; it must be

Merge pull request #4646 from pallets/cli-app-envDavid Lordbefore adoptionae54727

lines 18–19why, one step back
18told where to find your application in order to use it. The ``--app``
19option is used to specify how to load the application.

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 20why, one step back
20

Merge pull request #4646 from pallets/cli-app-envDavid Lordbefore adoptionae54727

line 21why, one step back
21While ``--app`` supports a variety of options for specifying your

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

lines 22–28why, one step back
22application, most use cases should be simple. Here are the typical values:
2324(nothing)25 The name "app" or "wsgi" is imported (as a ".py" file, or package),26 automatically detecting an app (``app`` or ``application``) or27 factory (``create_app`` or ``make_app``).28

Merge pull request #4646 from pallets/cli-app-envDavid Lordbefore adoptionae54727

line 29why, one step back
29``--app hello``

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

lines 30–34why, one step back
30 The given name is imported, automatically detecting an app (``app``
31 or ``application``) or factory (``create_app`` or ``make_app``).3233----34

Merge pull request #4646 from pallets/cli-app-envDavid Lordbefore adoptionae54727

line 35why, one step back
35``--app`` has three parts: an optional path that sets the current working

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

lines 36–40why, one step back
36directory, a Python file or dotted import path, and an optional variable
37name of the instance or factory. If the name is a factory, it can optionally38be followed by arguments in parentheses. The following values demonstrate these39parts:40

Merge pull request #4646 from pallets/cli-app-envDavid Lordbefore adoptionae54727

line 41why, one step back
41``--app src/hello``

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

lines 42–43why, one step back
42 Sets the current working directory to ``src`` then imports ``hello``.
43

Merge pull request #4646 from pallets/cli-app-envDavid Lordbefore adoptionae54727

line 44why, one step back
44``--app hello.web``

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

lines 45–46why, one step back
45 Imports the path ``hello.web``.
46

Merge pull request #4646 from pallets/cli-app-envDavid Lordbefore adoptionae54727

line 47why, one step back
47``--app hello:app2``

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

lines 48–49why, one step back
48 Uses the ``app2`` Flask instance in ``hello``.
49

Merge pull request #4646 from pallets/cli-app-envDavid Lordbefore adoptionae54727

line 50why, one step back
50``--app 'hello:create_app("dev")'``

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

lines 51–53why, one step back
51 The ``create_app`` factory in ``hello`` is called with the string ``'dev'``
52 as the argument.53

Merge pull request #4646 from pallets/cli-app-envDavid Lordbefore adoptionae54727

line 54why, one step back
54If ``--app`` is not set, the command will try to import "app" or

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

lines 55–73why, one step back
55"wsgi" (as a ".py" file, or package) and try to detect an application
56instance or factory.5758Within the given import, the command looks for an application instance named59``app`` or ``application``, then any application instance. If no instance is60found, the command looks for a factory function named ``create_app`` or61``make_app`` that returns an instance.6263If parentheses follow the factory name, their contents are parsed as64Python literals and passed as arguments and keyword arguments to the65function. This means that strings must still be in quotes.666768Run the Development Server69--------------------------7071The :func:`run <cli.run_command>` command will start the development server. It72replaces the :meth:`Flask.run` method in most cases. ::73

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

line 74why, one step back
74 $ flask --app hello run

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

lines 75–82why, one step back
75 * Serving Flask app "hello"
76 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)7778.. warning:: Do not use this command to run your application in production.79 Only use the development server during development. The development server80 is provided for convenience, but is not designed to be particularly secure,81 stable, or efficient. See :doc:`/deploying/index` for how to run in production.82

Merge branch '2.0.x'David Lordbefore adoptionedac7e3

lines 83–87why, one step back
83If another program is already using port 5000, you'll see
84``OSError: [Errno 98]`` or ``OSError: [WinError 10013]`` when the85server tries to start. See :ref:`address-already-in-use` for how to86handle that.87

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 88why, one step back
88

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

lines 89–90why, one step back
89Debug Mode
90~~~~~~~~~~

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 91why, one step back
91

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

lines 92–94why, one step back
92In debug mode, the ``flask run`` command will enable the interactive debugger and the
93reloader by default, and make errors easier to see and debug. To enable debug mode, use94the ``--debug`` option.

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 95why, one step back
95

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

line 96why, one step back
96.. code-block:: console

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 97why, one step back
97

Merge pull request #4980 from pallets/release-2.2.3David Lordbefore adoption6a392af

line 98why, one step back
98 $ flask --app hello run --debug

Merge pull request #4646 from pallets/cli-app-envDavid Lordbefore adoptionae54727

lines 99–104why, one step back
99 * Serving Flask app "hello"
100 * Debug mode: on101 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)102 * Restarting with inotify reloader103 * Debugger is active!104 * Debugger PIN: 223-456-919

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 105why, one step back
105

Merge pull request #4980 from pallets/release-2.2.3David Lordbefore adoption6a392af

lines 106–107why, one step back
106The ``--debug`` option can also be passed to the top level ``flask`` command to enable
107debug mode for any command. The following two ``run`` calls are equivalent.

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 108why, one step back
108

Merge pull request #4980 from pallets/release-2.2.3David Lordbefore adoption6a392af

lines 109–114why, one step back
109.. code-block:: console
110111 $ flask --app hello --debug run112 $ flask --app hello run --debug113114

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

lines 115–116why, one step back
115Watch and Ignore Files with the Reloader
116~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 117why, one step back
117

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

lines 118–120why, one step back
118When using debug mode, the reloader will trigger whenever your Python code or imported
119modules change. The reloader can watch additional files with the ``--extra-files``120option. Multiple paths are separated with ``:``, or ``;`` on Windows.

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 121why, one step back
121

Merge pull request #4646 from pallets/cli-app-envDavid Lordbefore adoptionae54727

line 122why, one step back
122.. code-block:: text

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 123why, one step back
123

Merge pull request #4646 from pallets/cli-app-envDavid Lordbefore adoptionae54727

lines 124–126why, one step back
124 $ flask run --extra-files file1:dirA/file2:dirB/
125 * Running on http://127.0.0.1:8000/126 * Detected change in '/path/to/file1', reloading

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 127why, one step back
127

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

lines 128–130why, one step back
128The reloader can also ignore files using :mod:`fnmatch` patterns with the
129``--exclude-patterns`` option. Multiple patterns are separated with ``:``, or ``;`` on130Windows.

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 131why, one step back
131

Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204

line 132why, one step back
132

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

lines 133–134why, one step back
133Open a Shell
134------------

Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204

line 135why, one step back
135

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

lines 136–138why, one step back
136To explore the data in your application, you can start an interactive Python
137shell with the :func:`shell <cli.shell_command>` command. An application138context will be active, and the app instance will be imported. ::

Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204

line 139why, one step back
139

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

lines 140–144why, one step back
140 $ flask shell
141 Python 3.10.0 (default, Oct 27 2021, 06:59:51) [GCC 11.1.0] on linux142 App: example [production]143 Instance: /home/david/Projects/pallets/flask/instance144 >>>

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 145why, one step back
145

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

line 146why, one step back
146Use :meth:`~Flask.shell_context_processor` to add other automatic imports.

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

lines 147–153why, one step back
147
148149.. _dotenv:150151Environment Variables From dotenv152---------------------------------153

Merge pull request #4646 from pallets/cli-app-envDavid Lordbefore adoptionae54727

lines 154–157why, one step back
154The ``flask`` command supports setting any option for any command with
155environment variables. The variables are named like ``FLASK_OPTION`` or156``FLASK_COMMAND_OPTION``, for example ``FLASK_APP`` or157``FLASK_RUN_PORT``.

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 158why, one step back
158

Merge pull request #4646 from pallets/cli-app-envDavid Lordbefore adoptionae54727

lines 159–162why, one step back
159Rather than passing options every time you run a command, or environment
160variables every time you open a new terminal, you can use Flask's dotenv161support to set environment variables automatically.162

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 163why, one step back
163If `python-dotenv`_ is installed, running the ``flask`` command will set

Merge pull request #4646 from pallets/cli-app-envDavid Lordbefore adoptionae54727

lines 164–168why, one step back
164environment variables defined in the files ``.env`` and ``.flaskenv``.
165You can also specify an extra file to load with the ``--env-file``166option. Dotenv files can be used to avoid having to set ``--app`` or167``FLASK_APP`` manually, and to set configuration using environment168variables similar to how some deployment services work.

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

lines 169–175why, one step back
169
170Variables set on the command line are used over those set in :file:`.env`,171which are used over those set in :file:`.flaskenv`. :file:`.flaskenv` should be172used for public variables, such as ``FLASK_APP``, while :file:`.env` should not173be committed to your repository so that it can set private variables.174175Directories are scanned upwards from the directory you call ``flask``

Merge remote-tracking branch 'origin/2.1.x'David Lordbefore adoptiona25d234

line 176why, one step back
176from to locate the files.

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

lines 177–202why, one step back
177
178The files are only loaded by the ``flask`` command or calling179:meth:`~Flask.run`. If you would like to load these files when running in180production, you should call :func:`~cli.load_dotenv` manually.181182.. _python-dotenv: https://github.com/theskumar/python-dotenv#readme183184185Setting Command Options186~~~~~~~~~~~~~~~~~~~~~~~187188Click is configured to load default values for command options from189environment variables. The variables use the pattern190``FLASK_COMMAND_OPTION``. For example, to set the port for the run191command, instead of ``flask run --port 8000``:192193.. tabs::194195 .. group-tab:: Bash196197 .. code-block:: text198199 $ export FLASK_RUN_PORT=8000200 $ flask run201 * Running on http://127.0.0.1:8000/202

Merge branch '2.0.x'David Lordbefore adoptione37e871

lines 203–210why, one step back
203 .. group-tab:: Fish
204205 .. code-block:: text206207 $ set -x FLASK_RUN_PORT 8000208 $ flask run209 * Running on http://127.0.0.1:8000/210

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

lines 211–257why, one step back
211 .. group-tab:: CMD
212213 .. code-block:: text214215 > set FLASK_RUN_PORT=8000216 > flask run217 * Running on http://127.0.0.1:8000/218219 .. group-tab:: Powershell220221 .. code-block:: text222223 > $env:FLASK_RUN_PORT = 8000224 > flask run225 * Running on http://127.0.0.1:8000/226227These can be added to the ``.flaskenv`` file just like ``FLASK_APP`` to228control default command options.229230231Disable dotenv232~~~~~~~~~~~~~~233234The ``flask`` command will show a message if it detects dotenv files but235python-dotenv is not installed.236237.. code-block:: bash238239 $ flask run240 * Tip: There are .env files present. Do "pip install python-dotenv" to use them.241242You can tell Flask not to load dotenv files even when python-dotenv is243installed by setting the ``FLASK_SKIP_DOTENV`` environment variable.244This can be useful if you want to load them manually, or if you're using245a project runner that loads them already. Keep in mind that the246environment variables must be set before the app loads or it won't247configure as expected.248249.. tabs::250251 .. group-tab:: Bash252253 .. code-block:: text254255 $ export FLASK_SKIP_DOTENV=1256 $ flask run257

Merge branch '2.0.x'David Lordbefore adoptione37e871

lines 258–264why, one step back
258 .. group-tab:: Fish
259260 .. code-block:: text261262 $ set -x FLASK_SKIP_DOTENV 1263 $ flask run264

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

lines 265–293why, one step back
265 .. group-tab:: CMD
266267 .. code-block:: text268269 > set FLASK_SKIP_DOTENV=1270 > flask run271272 .. group-tab:: Powershell273274 .. code-block:: text275276 > $env:FLASK_SKIP_DOTENV = 1277 > flask run278279280Environment Variables From virtualenv281-------------------------------------282283If you do not want to install dotenv support, you can still set environment284variables by adding them to the end of the virtualenv's :file:`activate`285script. Activating the virtualenv will set the variables.286287.. tabs::288289 .. group-tab:: Bash290291 Unix Bash, :file:`venv/bin/activate`::292293 $ export FLASK_APP=hello

Merge branch '2.0.x'David Lordbefore adoptione37e871

lines 294–299why, one step back
294
295 .. group-tab:: Fish296297 Fish, :file:`venv/bin/activate.fish`::298299 $ set -x FLASK_APP hello

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

lines 300–423why, one step back
300
301 .. group-tab:: CMD302303 Windows CMD, :file:`venv\\Scripts\\activate.bat`::304305 > set FLASK_APP=hello306307 .. group-tab:: Powershell308309 Windows Powershell, :file:`venv\\Scripts\\activate.ps1`::310311 > $env:FLASK_APP = "hello"312313It is preferred to use dotenv support over this, since :file:`.flaskenv` can be314committed to the repository so that it works automatically wherever the project315is checked out.316317318Custom Commands319---------------320321The ``flask`` command is implemented using `Click`_. See that project's322documentation for full information about writing commands.323324This example adds the command ``create-user`` that takes the argument325``name``. ::326327 import click328 from flask import Flask329330 app = Flask(__name__)331332 @app.cli.command("create-user")333 @click.argument("name")334 def create_user(name):335 ...336337::338339 $ flask create-user admin340341This example adds the same command, but as ``user create``, a command in a342group. This is useful if you want to organize multiple related commands. ::343344 import click345 from flask import Flask346 from flask.cli import AppGroup347348 app = Flask(__name__)349 user_cli = AppGroup('user')350351 @user_cli.command('create')352 @click.argument('name')353 def create_user(name):354 ...355356 app.cli.add_command(user_cli)357358::359360 $ flask user create demo361362See :ref:`testing-cli` for an overview of how to test your custom363commands.364365366Registering Commands with Blueprints367~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~368369If your application uses blueprints, you can optionally register CLI370commands directly onto them. When your blueprint is registered onto your371application, the associated commands will be available to the ``flask``372command. By default, those commands will be nested in a group matching373the name of the blueprint.374375.. code-block:: python376377 from flask import Blueprint378379 bp = Blueprint('students', __name__)380381 @bp.cli.command('create')382 @click.argument('name')383 def create(name):384 ...385386 app.register_blueprint(bp)387388.. code-block:: text389390 $ flask students create alice391392You can alter the group name by specifying the ``cli_group`` parameter393when creating the :class:`Blueprint` object, or later with394:meth:`app.register_blueprint(bp, cli_group='...') <Flask.register_blueprint>`.395The following are equivalent:396397.. code-block:: python398399 bp = Blueprint('students', __name__, cli_group='other')400 # or401 app.register_blueprint(bp, cli_group='other')402403.. code-block:: text404405 $ flask other create alice406407Specifying ``cli_group=None`` will remove the nesting and merge the408commands directly to the application's level:409410.. code-block:: python411412 bp = Blueprint('students', __name__, cli_group=None)413 # or414 app.register_blueprint(bp, cli_group=None)415416.. code-block:: text417418 $ flask create alice419420421Application Context422~~~~~~~~~~~~~~~~~~~423

Merge pull request #4647 from pallets/cli-app_contextDavid Lordbefore adoptioncec5f74

lines 424–429why, one step back
424Commands added using the Flask app's :attr:`~Flask.cli` or
425:class:`~flask.cli.FlaskGroup` :meth:`~cli.AppGroup.command` decorator426will be executed with an application context pushed, so your custom427commands and parameters have access to the app and its configuration. The428:func:`~cli.with_appcontext` decorator can be used to get the same429behavior, but is not needed in most cases.

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 430why, one step back
430

Merge pull request #4647 from pallets/cli-app_contextDavid Lordbefore adoptioncec5f74

lines 431–432why, one step back
431.. code-block:: python
432

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

lines 433–484why, one step back
433 import click
434 from flask.cli import with_appcontext435436 @click.command()437 @with_appcontext438 def do_work():439 ...440441 app.cli.add_command(do_work)442443444Plugins445-------446447Flask will automatically load commands specified in the ``flask.commands``448`entry point`_. This is useful for extensions that want to add commands when449they are installed. Entry points are specified in :file:`setup.py` ::450451 from setuptools import setup452453 setup(454 name='flask-my-extension',455 ...,456 entry_points={457 'flask.commands': [458 'my-command=flask_my_extension.commands:cli'459 ],460 },461 )462463464.. _entry point: https://packaging.python.org/tutorials/packaging-projects/#entry-points465466Inside :file:`flask_my_extension/commands.py` you can then export a Click467object::468469 import click470471 @click.command()472 def cli():473 ...474475Once that package is installed in the same virtualenv as your Flask project,476you can run ``flask my-command`` to invoke the command.477478479.. _custom-scripts:480481Custom Scripts482--------------483484When you are using the app factory pattern, it may be more convenient to define

Merge pull request #4646 from pallets/cli-app-envDavid Lordbefore adoptionae54727

line 485why, one step back
485your own Click script. Instead of using ``--app`` and letting Flask load

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

lines 486–518why, one step back
486your application, you can create your own Click object and export it as a
487`console script`_ entry point.488489Create an instance of :class:`~cli.FlaskGroup` and pass it the factory::490491 import click492 from flask import Flask493 from flask.cli import FlaskGroup494495 def create_app():496 app = Flask('wiki')497 # other setup498 return app499500 @click.group(cls=FlaskGroup, create_app=create_app)501 def cli():502 """Management script for the Wiki application."""503504Define the entry point in :file:`setup.py`::505506 from setuptools import setup507508 setup(509 name='flask-my-extension',510 ...,511 entry_points={512 'console_scripts': [513 'wiki=wiki:cli'514 ],515 },516 )517518Install the application in the virtualenv in editable mode and the custom

Merge pull request #4646 from pallets/cli-app-envDavid Lordbefore adoptionae54727

line 519why, one step back
519script is available. Note that you don't need to set ``--app``. ::

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

lines 520–538why, one step back
520
521 $ pip install -e .522 $ wiki run523524.. admonition:: Errors in Custom Scripts525526 When using a custom script, if you introduce an error in your527 module-level code, the reloader will fail because it can no longer528 load the entry point.529530 The ``flask`` command, being separate from your code, does not have531 this issue and is recommended in most cases.532533.. _console script: https://packaging.python.org/tutorials/packaging-projects/#console-scripts534535536PyCharm Integration537-------------------538

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

lines 539–542why, one step back
539PyCharm Professional provides a special Flask run configuration to run the development
540server. For the Community Edition, and for other commands besides ``run``, you need to541create a custom run configuration. These instructions should be similar for any other542IDE you use.

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 543why, one step back
543

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

lines 544–545why, one step back
544In PyCharm, with your project open, click on *Run* from the menu bar and go to *Edit
545Configurations*. You'll see a screen similar to this:

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 546why, one step back
546

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

line 547why, one step back
547.. image:: _static/pycharm-run-config.png

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

lines 548–549why, one step back
548 :align: center
549 :class: screenshot

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

line 550why, one step back
550 :alt: Screenshot of PyCharm run configuration.

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 551why, one step back
551

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

lines 552–553why, one step back
552Once you create a configuration for the ``flask run``, you can copy and change it to
553call any other command.

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 554why, one step back
554

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

lines 555–556why, one step back
555Click the *+ (Add New Configuration)* button and select *Python*. Give the configuration
556a name such as "flask run".

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 557why, one step back
557

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

line 558why, one step back
558Click the *Script path* dropdown and change it to *Module name*, then input ``flask``.

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 559why, one step back
559

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

line 560why, one step back
560The *Parameters* field is set to the CLI command to execute along with any arguments.

Merge pull request #4980 from pallets/release-2.2.3David Lordbefore adoption6a392af

line 561why, one step back
561This example uses ``--app hello run --debug``, which will run the development server in

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

line 562why, one step back
562debug mode. ``--app hello`` should be the import or file with your Flask app.

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 563why, one step back
563

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

lines 564–565why, one step back
564If you installed your project as a package in your virtualenv, you may uncheck the
565*PYTHONPATH* options. This will more accurately match how you deploy later.

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 566why, one step back
566

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

lines 567–568why, one step back
567Click *OK* to save and close the configuration. Select the configuration in the main
568PyCharm window and click the play button next to it to run the server.

Merge remote-tracking branch 'origin/2.0.x'David Lordbefore adoption4240ace

line 569why, one step back
569

Merge pull request #4720 from pallets/deprecate-envDavid Lordbefore adoption98ca00d

lines 570–571why, one step back
570Now that you have a configuration for ``flask run``, you can copy that configuration and
571change the *Parameters* argument to run a different CLI command.