Skip to content
Myr

Merge branch '2.0.x'

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

authored by David Lord · committed by David Lord · parents 93a7f08, 1a1c7ea · Browse files · 4 files+40 added−13 removed
This commit

State

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

Diff stats

4 files+40 added−13 removed

  • other:+40 added−13 removed

4 files+40 added−13 removed

modified:docs/server.rst+13 added-6 removed
78 unmodified lines
7980Either identify and stop the other program, or use81``flask run --port 5001`` to pick a different port.8283You can use ``netstat`` to identify what process id is using a port,84then use other operating system tools stop that process. The following85example shows that process id 6847 is using port 5000.83You can use ``netstat`` or ``lsof`` to identify what process id is using84a port, then use other operating system tools stop that process. The85following example shows that process id 6847 is using port 5000.8687.. tabs::8889 .. group-tab:: Linux/Mac89 .. tab:: ``netstat`` (Linux)9091 .. code-block:: text9293 $ netstat -nlp | grep 500094 tcp 0 0 127.0.0.1:5000 0.0.0.0:* LISTEN 6847/python9596 .. group-tab:: Windows96 .. tab:: ``lsof`` (macOS / Linux)9798 .. code-block:: text99100 $ lsof -P -i :5000101 Python 6847 IPv4 TCP localhost:5000 (LISTEN)102103 .. tab:: ``netstat`` (Windows)104105 .. code-block:: text106107 > netstat -ano | findstr 5000108 TCP 127.0.0.1:5000 0.0.0.0:0 LISTENING 6847109103MacOS Monterey and later automatically starts a service that uses port110macOS Monterey and later automatically starts a service that uses port1115000. To disable the service, go to System Preferences, Sharing, and112disable "AirPlay Receiver".113114
43 unmodified lines
modified:src/flask/json/__init__.py+9 added-3 removed
72 unmodified lines
73 bp = app.blueprints.get(request.blueprint) if request else None # type: ignore74 if bp is not None and bp.json_encoder is not None:75 cls = bp.json_encoder7677 # Only set a custom encoder if it has custom behavior. This is78 # faster on PyPy.79 if cls is not _json.JSONEncoder:80 kwargs.setdefault("cls", cls)8182 kwargs.setdefault("cls", cls)83 kwargs.setdefault("ensure_ascii", app.config["JSON_AS_ASCII"])84 kwargs.setdefault("sort_keys", app.config["JSON_SORT_KEYS"])85 else:
13 unmodified lines
99 bp = app.blueprints.get(request.blueprint) if request else None # type: ignore100 if bp is not None and bp.json_decoder is not None:101 cls = bp.json_decoder10298 kwargs.setdefault("cls", cls)99 else:100 kwargs.setdefault("cls", JSONDecoder)103 # Only set a custom decoder if it has custom behavior. This is104 # faster on PyPy.105 if cls not in {JSONDecoder, _json.JSONDecoder}:106 kwargs.setdefault("cls", cls)107108109def dumps(obj: t.Any, app: t.Optional["Flask"] = None, **kwargs: t.Any) -> str:110 """Serialize an object to a string of JSON.
189 unmodified lines
modified:src/flask/ctx.py+13 added-4 removed
128 unmodified lines
129 some headers without converting the return value into a response object.130131 .. versionadded:: 0.9132 """133 top = _request_ctx_stack.top134135 if top is None:136 raise RuntimeError(137 "This decorator can only be used when a request context is"138 " active, such as within a view function."139 )140133 _request_ctx_stack.top._after_request_functions.append(f)141 top._after_request_functions.append(f)142 return f143144145def copy_current_request_context(f: t.Callable) -> t.Callable:
20 unmodified lines
166167 .. versionadded:: 0.10168 """169 top = _request_ctx_stack.top170171 if top is None:172 raise RuntimeError(164 "This decorator can only be used at local scopes "165 "when a request context is on the stack. For instance within "166 "view functions."173 "This decorator can only be used when a request context is"174 " active, such as within a view function."175 )176177 reqctx = top.copy()178179 def wrapper(*args, **kwargs):180 with reqctx:
327 unmodified lines
modified:CHANGES.rst+5 added
45 unmodified lines
46 2.0.x. Use ``response.request.environ`` instead. :pr:`4341`47- Fix type annotation for ``errorhandler`` decorator. :issue:`4295`48- Revert a change to the CLI that caused it to hide ``ImportError``49 tracebacks when importing the application. :issue:`4307`50- ``app.json_encoder`` and ``json_decoder`` are only passed to51 ``dumps`` and ``loads`` if they have custom behavior. This improves52 performance, mainly on PyPy. :issue:`4349`53- Clearer error message when ``after_this_request`` is used outside a54 request context. :issue:`4333`555657Version 2.0.258-------------
1180 unmodified lines