Merge branch '2.0.x'

This commit is contained in:
David Lord 2021-12-22 15:21:31 -08:00
commit edac7e3a56
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
11 changed files with 122 additions and 65 deletions

View file

@ -2,7 +2,7 @@ ci:
autoupdate_schedule: monthly
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.29.0
rev: v2.29.1
hooks:
- id: pyupgrade
args: ["--py36-plus"]
@ -14,7 +14,7 @@ repos:
files: "^(?!examples/)"
args: ["--application-directories", "src"]
- repo: https://github.com/psf/black
rev: 21.10b0
rev: 21.12b0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8

View file

@ -103,6 +103,11 @@ replaces the :meth:`Flask.run` method in most cases. ::
is provided for convenience, but is not designed to be particularly secure,
stable, or efficient. See :doc:`/deploying/index` for how to run in production.
If another program is already using port 5000, you'll see
``OSError: [Errno 98]`` or ``OSError: [WinError 10013]`` when the
server tries to start. See :ref:`address-already-in-use` for how to
handle that.
Open a Shell
------------

View file

@ -83,6 +83,11 @@ deployment options see :doc:`deploying/index`.
Now head over to http://127.0.0.1:5000/, and you should see your hello
world greeting.
If another program is already using port 5000, you'll see
``OSError: [Errno 98]`` or ``OSError: [WinError 10013]`` when the
server tries to start. See :ref:`address-already-in-use` for how to
handle that.
.. _public-server:
.. admonition:: Externally Visible Server

View file

@ -64,6 +64,47 @@ and using the CLI.
above.
.. _address-already-in-use:
Address already in use
~~~~~~~~~~~~~~~~~~~~~~
If another program is already using port 5000, you'll see an ``OSError``
when the server tries to start. It may have one of the following
messages:
- ``OSError: [Errno 98] Address already in use``
- ``OSError: [WinError 10013] An attempt was made to access a socket
in a way forbidden by its access permissions``
Either identify and stop the other program, or use
``flask run --port 5001`` to pick a different port.
You can use ``netstat`` to identify what process id is using a port,
then use other operating system tools stop that process. The following
example shows that process id 6847 is using port 5000.
.. tabs::
.. group-tab:: Linux/Mac
.. code-block:: text
$ netstat -nlp | grep 5000
tcp 0 0 127.0.0.1:5000 0.0.0.0:* LISTEN 6847/python
.. group-tab:: Windows
.. code-block:: text
> netstat -ano | findstr 5000
TCP 127.0.0.1:5000 0.0.0.0:0 LISTENING 6847
MacOS Monterey and later automatically starts a service that uses port
5000. To disable the service, go to System Preferences, Sharing, and
disable "AirPlay Receiver".
Lazy or Eager Loading
~~~~~~~~~~~~~~~~~~~~~

View file

@ -177,4 +177,9 @@ 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
web application!
If another program is already using port 5000, you'll see
``OSError: [Errno 98]`` or ``OSError: [WinError 10013]`` when the
server tries to start. See :ref:`address-already-in-use` for how to
handle that.
Continue to :doc:`database`.

View file

@ -57,29 +57,29 @@ By the end, your project layout will look like this:
/home/user/Projects/flask-tutorial
├── flaskr/
   ├── __init__.py
   ├── db.py
   ├── schema.sql
   ├── auth.py
   ├── blog.py
   ├── templates/
   │ ├── base.html
   │ ├── auth/
   │ │   ├── login.html
   │ │   └── register.html
   │ └── blog/
   │ ├── create.html
   │ ├── index.html
   │ └── update.html
   └── static/
      └── style.css
├── __init__.py
├── db.py
├── schema.sql
├── auth.py
├── blog.py
├── templates/
│ ├── base.html
│ ├── auth/
│ │ ├── login.html
│ │ └── register.html
│ └── blog/
│ ├── create.html
│ ├── index.html
│ └── update.html
└── static/
└── style.css
├── tests/
   ├── conftest.py
  ├── data.sql
   ├── test_factory.py
   ├── test_db.py
  ├── test_auth.py
  └── test_blog.py
├── conftest.py
├── data.sql
├── test_factory.py
├── test_db.py
├── test_auth.py
└── test_blog.py
├── venv/
├── setup.py
└── MANIFEST.in

View file

@ -12,7 +12,7 @@ attrs==21.2.0
# via pytest
babel==2.9.1
# via sphinx
backports.entry-points-selectable==1.1.0
backports.entry-points-selectable==1.1.1
# via virtualenv
blinker==1.4
# via -r requirements/tests.in
@ -22,49 +22,49 @@ cffi==1.15.0
# via cryptography
cfgv==3.3.1
# via pre-commit
charset-normalizer==2.0.7
charset-normalizer==2.0.9
# via requests
click==8.0.3
# via pip-tools
cryptography==35.0.0
cryptography==36.0.1
# via -r requirements/typing.in
distlib==0.3.3
distlib==0.3.4
# via virtualenv
docutils==0.16
# via
# sphinx
# sphinx-tabs
filelock==3.3.2
filelock==3.4.0
# via
# tox
# virtualenv
greenlet==1.1.2 ; python_version < "3.11"
# via -r requirements/tests.in
identify==2.3.3
identify==2.4.0
# via pre-commit
idna==3.3
# via requests
imagesize==1.2.0
imagesize==1.3.0
# via sphinx
iniconfig==1.1.1
# via pytest
jinja2==3.0.2
jinja2==3.0.3
# via sphinx
markupsafe==2.0.1
# via jinja2
mypy==0.910
mypy==0.930
# via -r requirements/typing.in
mypy-extensions==0.4.3
# via mypy
nodeenv==1.6.0
# via pre-commit
packaging==21.2
packaging==21.3
# via
# pallets-sphinx-themes
# pytest
# sphinx
# tox
pallets-sphinx-themes==2.0.1
pallets-sphinx-themes==2.0.2
# via -r requirements/docs.in
pep517==0.12.0
# via pip-tools
@ -76,23 +76,23 @@ pluggy==1.0.0
# via
# pytest
# tox
pre-commit==2.15.0
pre-commit==2.16.0
# via -r requirements/dev.in
py==1.11.0
# via
# pytest
# tox
pycparser==2.20
pycparser==2.21
# via cffi
pygments==2.10.0
# via
# sphinx
# sphinx-tabs
pyparsing==2.4.7
pyparsing==3.0.6
# via packaging
pytest==6.2.5
# via -r requirements/tests.in
python-dotenv==0.19.1
python-dotenv==0.19.2
# via -r requirements/tests.in
pytz==2021.3
# via babel
@ -104,9 +104,9 @@ six==1.16.0
# via
# tox
# virtualenv
snowballstemmer==2.1.0
snowballstemmer==2.2.0
# via sphinx
sphinx==4.2.0
sphinx==4.3.2
# via
# -r requirements/docs.in
# pallets-sphinx-themes
@ -133,21 +133,22 @@ sphinxcontrib-serializinghtml==1.1.5
# via sphinx
toml==0.10.2
# via
# mypy
# pre-commit
# pytest
# tox
tomli==1.2.2
# via pep517
tomli==2.0.0
# via
# mypy
# pep517
tox==3.24.4
# via -r requirements/dev.in
types-contextvars==2.4.0
# via -r requirements/typing.in
types-dataclasses==0.6.1
# via -r requirements/typing.in
types-setuptools==57.4.2
types-setuptools==57.4.4
# via -r requirements/typing.in
typing-extensions==3.10.0.2
typing-extensions==4.0.1
# via mypy
urllib3==1.26.7
# via requests
@ -155,7 +156,7 @@ virtualenv==20.10.0
# via
# pre-commit
# tox
wheel==0.37.0
wheel==0.37.1
# via pip-tools
# The following packages are considered to be unsafe in a requirements file:

View file

@ -10,7 +10,7 @@ babel==2.9.1
# via sphinx
certifi==2021.10.8
# via requests
charset-normalizer==2.0.7
charset-normalizer==2.0.9
# via requests
docutils==0.16
# via
@ -18,31 +18,31 @@ docutils==0.16
# sphinx-tabs
idna==3.3
# via requests
imagesize==1.2.0
imagesize==1.3.0
# via sphinx
jinja2==3.0.2
jinja2==3.0.3
# via sphinx
markupsafe==2.0.1
# via jinja2
packaging==21.2
packaging==21.3
# via
# pallets-sphinx-themes
# sphinx
pallets-sphinx-themes==2.0.1
pallets-sphinx-themes==2.0.2
# via -r requirements/docs.in
pygments==2.10.0
# via
# sphinx
# sphinx-tabs
pyparsing==2.4.7
pyparsing==3.0.6
# via packaging
pytz==2021.3
# via babel
requests==2.26.0
# via sphinx
snowballstemmer==2.1.0
snowballstemmer==2.2.0
# via sphinx
sphinx==4.2.0
sphinx==4.3.2
# via
# -r requirements/docs.in
# pallets-sphinx-themes

View file

@ -14,17 +14,17 @@ greenlet==1.1.2 ; python_version < "3.11"
# via -r requirements/tests.in
iniconfig==1.1.1
# via pytest
packaging==21.2
packaging==21.3
# via pytest
pluggy==1.0.0
# via pytest
py==1.11.0
# via pytest
pyparsing==2.4.7
pyparsing==3.0.6
# via packaging
pytest==6.2.5
# via -r requirements/tests.in
python-dotenv==0.19.1
python-dotenv==0.19.2
# via -r requirements/tests.in
toml==0.10.2
# via pytest

View file

@ -6,21 +6,21 @@
#
cffi==1.15.0
# via cryptography
cryptography==35.0.0
cryptography==36.0.1
# via -r requirements/typing.in
mypy==0.910
mypy==0.930
# via -r requirements/typing.in
mypy-extensions==0.4.3
# via mypy
pycparser==2.20
pycparser==2.21
# via cffi
toml==0.10.2
tomli==2.0.0
# via mypy
types-contextvars==2.4.0
# via -r requirements/typing.in
types-dataclasses==0.6.1
# via -r requirements/typing.in
types-setuptools==57.4.2
types-setuptools==57.4.4
# via -r requirements/typing.in
typing-extensions==3.10.0.2
typing-extensions==4.0.1
# via mypy

View file

@ -689,7 +689,7 @@ def get_root_path(import_name: str) -> str:
# Module already imported and has a file attribute. Use that first.
mod = sys.modules.get(import_name)
if mod is not None and hasattr(mod, "__file__"):
if mod is not None and hasattr(mod, "__file__") and mod.__file__ is not None:
return os.path.dirname(os.path.abspath(mod.__file__))
# Next attempt: check the loader.