forked from orbit-oss/flask
prefer --app over FLASK_APP in docs
This commit is contained in:
parent
99fa3c36ab
commit
ab1fbef29a
15 changed files with 147 additions and 580 deletions
|
|
@ -196,15 +196,13 @@ previous page.
|
|||
If you're still running the server from the previous page, you can
|
||||
either stop the server, or run this command in a new terminal. If
|
||||
you use a new terminal, remember to change to your project directory
|
||||
and activate the env as described in :doc:`/installation`. You'll
|
||||
also need to set ``FLASK_APP`` and ``FLASK_ENV`` as shown on the
|
||||
previous page.
|
||||
and activate the env as described in :doc:`/installation`.
|
||||
|
||||
Run the ``init-db`` command:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
$ flask init-db
|
||||
$ flask --app flaskr init-db
|
||||
Initialized the database.
|
||||
|
||||
There will now be a ``flaskr.sqlite`` file in the ``instance`` folder in
|
||||
|
|
|
|||
|
|
@ -48,35 +48,9 @@ Pip will install your project along with its dependencies.
|
|||
Since this is a different machine, you need to run ``init-db`` again to
|
||||
create the database in the instance folder.
|
||||
|
||||
.. tabs::
|
||||
.. code-block:: text
|
||||
|
||||
.. group-tab:: Bash
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
$ export FLASK_APP=flaskr
|
||||
$ flask init-db
|
||||
|
||||
.. group-tab:: Fish
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
$ set -x FLASK_APP flaskr
|
||||
$ flask init-db
|
||||
|
||||
.. group-tab:: CMD
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
> set FLASK_APP=flaskr
|
||||
> flask init-db
|
||||
|
||||
.. group-tab:: Powershell
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
> $env:FLASK_APP = "flaskr"
|
||||
> flask init-db
|
||||
$ flask --app flaskr init-db
|
||||
|
||||
When Flask detects that it's installed (not in editable mode), it uses
|
||||
a different directory for the instance folder. You can find it at
|
||||
|
|
@ -127,7 +101,7 @@ first install it in the virtual environment:
|
|||
$ pip install waitress
|
||||
|
||||
You need to tell Waitress about your application, but it doesn't use
|
||||
``FLASK_APP`` like ``flask run`` does. You need to tell it to import and
|
||||
``--app`` like ``flask run`` does. You need to tell it to import and
|
||||
call the application factory to get an application object.
|
||||
|
||||
.. code-block:: none
|
||||
|
|
|
|||
|
|
@ -135,43 +135,13 @@ exception, and restarts the server whenever you make changes to the
|
|||
code. You can leave it running and just reload the browser page as you
|
||||
follow the tutorial.
|
||||
|
||||
.. tabs::
|
||||
.. code-block:: text
|
||||
|
||||
.. group-tab:: Bash
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
$ export FLASK_APP=flaskr
|
||||
$ export FLASK_ENV=development
|
||||
$ flask run
|
||||
|
||||
.. group-tab:: Fish
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
$ set -x FLASK_APP flaskr
|
||||
$ set -x FLASK_ENV development
|
||||
$ flask run
|
||||
|
||||
.. group-tab:: CMD
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
> set FLASK_APP=flaskr
|
||||
> set FLASK_ENV=development
|
||||
> flask run
|
||||
|
||||
.. group-tab:: Powershell
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
> $env:FLASK_APP = "flaskr"
|
||||
> $env:FLASK_ENV = "development"
|
||||
> flask run
|
||||
$ flask --app flaskr --env development run
|
||||
|
||||
You'll see output similar to this:
|
||||
|
||||
.. code-block:: none
|
||||
.. code-block:: text
|
||||
|
||||
* Serving Flask app "flaskr"
|
||||
* Environment: development
|
||||
|
|
@ -179,7 +149,7 @@ You'll see output similar to this:
|
|||
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
* Restarting with stat
|
||||
* Debugger is active!
|
||||
* Debugger PIN: 855-212-761
|
||||
* Debugger PIN: nnn-nnn-nnn
|
||||
|
||||
Visit http://127.0.0.1:5000/hello in a browser and you should see the
|
||||
"Hello, World!" message. Congratulations, you're now running your Flask
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ You can observe that the project is now installed with ``pip list``.
|
|||
wheel 0.30.0
|
||||
|
||||
Nothing changes from how you've been running your project so far.
|
||||
``FLASK_APP`` is still set to ``flaskr`` and ``flask run`` still runs
|
||||
``--app`` is still set to ``flaskr`` and ``flask run`` still runs
|
||||
the application, but you can call it from anywhere, not just the
|
||||
``flask-tutorial`` directory.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue