Total Complexity | 4 |
Total Lines | 25 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import abc |
||
19 | class Runner(AbstractRunner): |
||
20 | def __init__(self, router: AbstractRouter) -> None: |
||
21 | self._router = router |
||
22 | |||
23 | def run(self, settings: Type[AbstractSettings]) -> None: |
||
24 | run_simple( |
||
25 | hostname=settings.hostname, |
||
26 | port=settings.port, |
||
27 | application=self._get_wsgi_app(), |
||
28 | use_reloader=True, |
||
29 | use_debugger=settings.debug, |
||
30 | ) |
||
31 | |||
32 | def _get_wsgi_app(self): |
||
33 | @WSGIRequest.application |
||
34 | def application(wsgi_request: WSGIRequest) -> WSGIResponse: |
||
35 | request_data = RequestData(wsgi_request) |
||
36 | request_func = self._router.dispatch( |
||
37 | request_data.path, request_data.method |
||
38 | ) |
||
39 | request = Request(request_data, request_func) |
||
40 | response = Response(request) |
||
41 | return response.wsgi() |
||
42 | |||
43 | return application |
||
44 |