zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
U
Þ=®d)
ã@sTdZddlmZddlZejrBddlmZddlmZddlm    Z    Gdd„dƒZ
dS)    aY
Application Dispatcher
======================
 
This middleware creates a single WSGI application that dispatches to
multiple other WSGI applications mounted at different URL paths.
 
A common example is writing a Single Page Application, where you have a
backend API and a frontend written in JavaScript that does the routing
in the browser rather than requesting different pages from the server.
The frontend is a single HTML and JS file that should be served for any
path besides "/api".
 
This example dispatches to an API app under "/api", an admin app
under "/admin", and an app that serves frontend files for all other
requests::
 
    app = DispatcherMiddleware(serve_frontend, {
        '/api': api_app,
        '/admin': admin_app,
    })
 
In production, you might instead handle this at the HTTP server level,
serving files or proxying to application servers based on location. The
API and admin apps would each be deployed with a separate WSGI server,
and the static files would be served directly by the HTTP server.
 
.. autoclass:: DispatcherMiddleware
 
:copyright: 2007 Pallets
:license: BSD-3-Clause
é)Ú annotationsN)Ú StartResponse)ÚWSGIApplication)ÚWSGIEnvironmentc@s6eZdZdZdddddœdd„Zd    d
d d œd d„ZdS)ÚDispatcherMiddlewareaJCombine multiple applications as a single WSGI application.
    Requests are dispatched to an application based on the path it is
    mounted under.
 
    :param app: The WSGI application to dispatch to if the request
        doesn't match a mounted path.
    :param mounts: Maps path prefixes to applications for dispatching.
    Nrz!dict[str, WSGIApplication] | NoneÚNone)ÚappÚmountsÚreturncCs||_|p i|_dS)N)rr    )Úselfrr    ©r úUd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\werkzeug/middleware/dispatcher.pyÚ__init__5szDispatcherMiddleware.__init__rrzt.Iterable[bytes])ÚenvironÚstart_responser
cCsˆ| dd¡}d}d|krN||jkr.|j|}q^| dd¡\}}d|›|›}q|j ||j¡}| dd¡}|||d<||d<|||ƒS)NZ    PATH_INFOÚú/éZ SCRIPT_NAME)Úgetr    Úrsplitr)r rrÚscriptZ    path_inforZ    last_itemZoriginal_script_namer r r Ú__call__=s 
 
  zDispatcherMiddleware.__call__)N)Ú__name__Ú
__module__Ú __qualname__Ú__doc__rrr r r r r+s ýr) rÚ
__future__rÚtypingÚtÚ TYPE_CHECKINGZ_typeshed.wsgirrrrr r r r Ú<module>s