ramka package#
Subpackages#
Submodules#
ramka.app module#
- class ramka.app.App(root_dir: str, *, router: Optional[BaseRouter] = None, router_kwargs: Optional[Dict] = None, template_engine: Optional[BaseTemplateEngine] = None, template_engine_kwargs: Optional[Dict] = None, static_files_dir: Optional[str] = None, static_files_engine: Optional[BaseStaticFilesEngine] = None, static_files_engine_kwargs: Optional[Dict] = None, http_404_not_found_handler: Optional[Callable] = None, http_405_method_not_allowed_handler: Optional[Callable] = None, error_handler: Optional[Callable] = None, middleware_classes: Optional[List[Type[Middleware]]] = None)#
Bases:
object
The main application class.
This is the entrypoint for the application.
- add_route(path: str, view: Union[BaseView, Callable], methods: Optional[List[str]] = None) None #
Add a route to the router.
It’s supposed to be used as a method.
- Parameters:
path (str) – The path to add the route to.
view (Union[BaseView, Callable]) – The view to add the route to.
methods (Optional[List[str]]) – The list of methods to add the route to.
- has_route(path: str) bool #
Check if the router has a route for the given path.
- Parameters:
path (str) – The path to check.
- Returns:
True if the router has a route for the given path, False otherwise.
- Return type:
bool
- route(path: str, methods: Optional[List[str]] = None) Callable #
Add a route to the router.
It’s supposed to be used as a decorator.
- Parameters:
path (str) – The path to add the route to.
methods (Optional[List[str]]) – The list of methods to add the route to.
- template(template_name, context: Optional[Dict[str, Any]] = None) Any #
Render a template using defined template engine.
- Parameters:
template_name (str) – The name of the template to render.
context (Optional[Dict[str, Any]]) – The context to use.
- Returns:
The rendered template.
- Return type:
Any