MCPcopy Index your code
hub / github.com/faif/python-patterns / Router

Class Router

patterns/structural/mvc.py:134–156  ·  view source on GitHub ↗

The Router is the entry point of the application.

Source from the content-addressed store, hash-verified

132
133
134class Router:
135 """The Router is the entry point of the application."""
136
137 def __init__(self):
138 self.routes = {}
139
140 def register(
141 self,
142 path: str,
143 controller_class: type[Controller],
144 model_class: type[Model],
145 view_class: type[View],
146 ) -> None:
147 model_instance: Model = model_class()
148 view_instance: View = view_class()
149 self.routes[path] = controller_class(model_instance, view_instance)
150
151 def resolve(self, path: str) -> Controller:
152 if self.routes.get(path):
153 controller: Controller = self.routes[path]
154 return controller
155 else:
156 raise KeyError(f"No controller registered for path '{path}'")
157
158
159def main():

Callers 2

mvc.pyFile · 0.85

Calls

no outgoing calls

Tested by 1