Skip to content
Myr

Merge pull request #2898 from rochacbruno/2897-Add-Extra-Files-to-CLI

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

Fix #2897 - Add `extra_files` option to `flask run` CLI

authored by David Lord · committed by GitHub · parents 4fe81d7, e18cc4d · Browse files · 3 files+47 added−2 removed
This commit

State

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

Diff stats

3 files+47 added−2 removed

  • other:+47 added−2 removed

3 files+47 added−2 removed

modified:docs/cli.rst+19 added
144 unmodified lines
145 * Debugger is active!146 * Debugger PIN: 223-456-919147148149Watch Extra Files with the Reloader150~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~151152When using development mode, the reloader will trigger whenever your153Python code or imported modules change. The reloader can watch154additional files with the ``--extra-files`` option, or the155``FLASK_RUN_EXTRA_FILES`` environment variable. Multiple paths are156separated with ``:``, or ``;`` on Windows.157158.. code-block:: none159160 $ flask run --extra-files file1:dirA/file2:dirB/161 # or162 $ export FLASK_RUN_EXTRA_FILES=file1:dirA/file2:dirB/163 $ flask run164 * Running on http://127.0.0.1:8000/165 * Detected change in '/path/to/file1', reloading166167168Debug Mode169----------170171Debug mode will be enabled when :envvar:`FLASK_ENV` is ``development``,
316 unmodified lines
modified:flask/cli.py+25 added-1 removed
740 unmodified lines
741742 return value743744745class SeparatedPathType(click.Path):746 """Click option type that accepts a list of values separated by the747 OS's path separator (``:``, ``;`` on Windows). Each value is748 validated as a :class:`click.Path` type.749 """750751 def convert(self, value, param, ctx):752 items = self.split_envvar_value(value)753 super_convert = super(SeparatedPathType, self).convert754 return [super_convert(item, param, ctx) for item in items]755756757@click.command("run", short_help="Run a development server.")758@click.option("--host", "-h", default="127.0.0.1", help="The interface to bind to.")759@click.option("--port", "-p", default=5000, help="The port to bind to.")760@click.option(
28 unmodified lines
789 "--with-threads/--without-threads",790 default=True,791 help="Enable or disable multithreading.",792)793@click.option(794 "--extra-files",795 default=None,796 type=SeparatedPathType(),797 help=(798 "Extra files that trigger a reload on change. Multiple paths"799 " are separated by '{}'.".format(os.path.pathsep)800 ),801)802@pass_script_info782def run_command(info, host, port, reload, debugger, eager_loading, with_threads, cert):803def run_command(804 info, host, port, reload, debugger, eager_loading, with_threads, cert, extra_files805):806 """Run a local development server.807808 This server is for development purposes only. It does not provide809 the stability, security, or performance of production WSGI servers.
24 unmodified lines
834 use_reloader=reload,835 use_debugger=debugger,836 threaded=with_threads,837 ssl_context=cert,838 extra_files=extra_files,839 )840841842@click.command("shell", short_help="Run a shell in the app context.")
106 unmodified lines
modified:CHANGES.rst+3 added-1 removed
47 unmodified lines
48 with the documentation. It will return ``False`` if python-dotenv is49 not installed, or if the given path isn't a file. :issue:`2937`50- Signaling support has a stub for the ``connect_via`` method when51 the Blinker library is not installed. :pr:`3208`52- Add an ``--extra-files`` option to the ``flask run`` CLI command to53 specify extra files that will trigger the reloader on change.54 :issue:`2897`5556.. _#2935: https://github.com/pallets/flask/issues/293557.. _#2957: https://github.com/pallets/flask/issues/295758.. _#2994: https://github.com/pallets/flask/pull/2994
30 unmodified lines
89.. _#2900: https://github.com/pallets/flask/issues/290090.. _#2933: https://github.com/pallets/flask/issues/293391.. _#2986: https://github.com/pallets/flask/pull/2986929093Version 1.0.294-------------9596Released 2018-05-02
909 unmodified lines