;i* jdZddlmZddlZejrddlmZddlmZddlm Z GddZ 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&eZdZdZ ddd ZddZdS)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. Napprmounts!dict[str, WSGIApplication] | NonereturnNonec&||_|pi|_dSN)r r )selfr r s RC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\werkzeug/middleware/dispatcher.py__init__zDispatcherMiddleware.__init__6s l environrstart_responsert.Iterable[bytes]cN|dd}d}d|vr;||jvr|j|}nD|dd\}}d||}d|v;|j||j}|dd}||z|d<||d<|||S)N PATH_INFO/ SCRIPT_NAME)getr rsplitr )rrrscript path_infor last_itemoriginal_script_names r__call__zDispatcherMiddleware.__call__>s["-- Vmm$$k&) & c1 5 5 FI2I2y22I Vmm+//&$(33C&{{="==!5!> ( s7N+++rr)r rr r r r )rrrrr r)__name__ __module__ __qualname____doc__rr#rrrr,sP59#####,,,,,,rr) r' __future__rtypingt TYPE_CHECKING_typeshed.wsgirrrrr(rrr.sB#"""""?/,,,,,,............%,%,%,%,%,%,%,%,%,%,r