mirror of
https://github.com/kennethreitz/replit-py.git
synced 2026-06-05 23:10:18 +00:00
Add init method and nice_jinja setting
This commit is contained in:
+18
-1
@@ -75,7 +75,24 @@ class App(flask.Flask):
|
||||
|
||||
request_class = Request
|
||||
|
||||
def login_wall(self, exclude: Set[str] = ("/",), handler: Callable = None) -> None:
|
||||
def __init__(
|
||||
self, import_name: str, nice_jinja: bool = True, **kwargs: Any
|
||||
) -> None:
|
||||
"""Initialize the app.
|
||||
|
||||
Args:
|
||||
import_name (str): The name of the app, usually __name__
|
||||
nice_jinja (bool): Whether to change jinja settings to make them
|
||||
prettier. Defaults to True.
|
||||
**kwargs (Any): Extra keyword arguments to be passed to the flask init
|
||||
function.
|
||||
"""
|
||||
super().__init__(import_name, **kwargs)
|
||||
if nice_jinja:
|
||||
self.jinja_env.trim_blocks = True
|
||||
self.jinja_env.lstrip_blocks = True
|
||||
|
||||
def login_wall(self, exclude: Set[str] = ("/",), handler: Callable = None,) -> None:
|
||||
"""Require users to be logged-in on all pages.
|
||||
|
||||
Args:
|
||||
|
||||
Reference in New Issue
Block a user