Skip to content

Commit b5a52ed

Browse files
committed
feat: add controller
1 parent d20a72c commit b5a52ed

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

examples/example_locale.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
from pyechonext.app import ApplicationType, EchoNext
55
from pyechonext.config import SettingsConfigType, SettingsLoader
66
from pyechonext.middleware import middlewares
7+
from pyechonext.mvc.controllers import PageController
78
from pyechonext.response import Response
89
from pyechonext.static import StaticFile
910
from pyechonext.template_engine.jinja import render_template
10-
from pyechonext.urls import URL, IndexView
11+
from pyechonext.urls import URL
1112
from pyechonext.utils.exceptions import MethodNotAllow
12-
from pyechonext.views import View
1313

1414

15-
class UsersView(View):
16-
def get(self, request, response, **kwargs):
15+
class UsersView(PageController):
16+
def get(self, request, response, *args, **kwargs):
1717
return render_template(
1818
request,
1919
"index.html",
@@ -22,11 +22,11 @@ def get(self, request, response, **kwargs):
2222
friends=["Bob", "Anna", "John"],
2323
)
2424

25-
def post(self, request, response, **kwargs):
25+
def post(self, request, response, *args, **kwargs):
2626
raise MethodNotAllow(f"Request {request.path}: method not allow")
2727

2828

29-
url_patterns = [URL(url="/", view=IndexView), URL(url="/users", view=UsersView)]
29+
url_patterns = [URL(path="/users", controller=UsersView)]
3030
config_loader = SettingsLoader(SettingsConfigType.PYMODULE, "el_config.py")
3131
settings = config_loader.get_settings()
3232
static_files = [StaticFile(settings, "styles.css")]
@@ -48,7 +48,7 @@ def api_docs(request, response):
4848

4949

5050
@echonext.route_page("/book")
51-
class BooksResource(View):
51+
class BooksResource(PageController):
5252
"""
5353
This class describes a books resource.
5454
"""

0 commit comments

Comments
 (0)