Skip to content

Commit 3979f8e

Browse files
authored
Add default 404 template to project templates
fletx.cli: Add default 404 template to project templates.
2 parents 07709b2 + 0d66295 commit 3979f8e

4 files changed

Lines changed: 88 additions & 16 deletions

File tree

fletx/cli/templates/project/app/pages/__init__.py.tpl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ Version: {{ version }}
66
"""
77

88
from .counter import CounterPage
9+
from .not_found import NotFoundPage
910

1011
__all__ = [
11-
'CounterPage'
12+
'CounterPage',
13+
'NotFoundPage'
1214
]
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import flet as ft
2+
from fletx.core import (
3+
FletXPage
4+
)
5+
from fletx.navigation import go_back
6+
7+
class NotFoundPage(FletXPage):
8+
"""Default 404 template"""
9+
10+
def __init__(self):
11+
super().__init__()
12+
13+
def build(self):
14+
return ft.Column(
15+
spacing = 10,
16+
expand = True,
17+
alignment = ft.MainAxisAlignment.CENTER,
18+
horizontal_alignment = ft.CrossAxisAlignment.CENTER,
19+
controls = [
20+
ft.Container(
21+
expand = True
22+
),
23+
ft.Row(
24+
spacing = 0,
25+
alignment = ft.MainAxisAlignment.CENTER,
26+
controls = [
27+
ft.Text(
28+
value = f'4',
29+
size = 100,
30+
weight = ft.FontWeight.BOLD
31+
),
32+
# LOGO USED AS 0
33+
ft.Image(
34+
src = 'logo.png',
35+
fit = ft.ImageFit.CONTAIN,
36+
width = 120,
37+
height = 120
38+
),
39+
ft.Text(
40+
value = f'4',
41+
size = 100,
42+
weight = ft.FontWeight.BOLD
43+
),
44+
]
45+
),
46+
47+
ft.Text(
48+
'PAGE NOT FOUND',
49+
size = 30,
50+
),
51+
ft.Text(
52+
'The page you were looking for could not be found.',
53+
size = 14,
54+
text_align = ft.TextAlign.CENTER
55+
),
56+
57+
ft.Container( # SPACER
58+
height = 20
59+
),
60+
61+
# GOBACK BUTTON
62+
ft.ElevatedButton(
63+
"Go back",
64+
icon = ft.Icons.ARROW_BACK_IOS,
65+
on_click=lambda e: go_back()
66+
),
67+
68+
ft.Container( # SPACER
69+
expand = True
70+
),
71+
72+
ft.Text('🚀 powered by FletX {{ fletx_version }}',color = ft.Colors.GREY_600),
73+
ft.Text('Python version {{ python_version }}', color = ft.Colors.GREY_600),
74+
75+
ft.Container( # SPACER
76+
height = 50,
77+
),
78+
]
79+
)

fletx/cli/templates/project/app/routes.py.tpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@ from fletx.navigation import (
1010
)
1111
from fletx.decorators import register_router
1212

13-
from .pages.counter import CounterPage
13+
from .pages import CounterPage, NotFoundPage
1414

1515
# Define {{ project_name | pascal_case }} routes here
1616
routes = [
1717
{
1818
'path': '/',
1919
'component': CounterPage,
2020
},
21+
{
22+
'path': '/**',
23+
'component': NotFoundPage,
24+
},
2125
]
2226
2327
@register_router
Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
11
# Core dependencies
2-
flet>=0.21.0
2+
flet>=0.28.3
33
fletxr>={{ fletx_version }}
4-
5-
# Development dependencies
6-
pytest>=7.0.0
7-
pytest-cov>=4.0.0
8-
black>=23.0.0
9-
flake8>=6.0.0
10-
mypy>=1.0.0
11-
12-
# Optional dependencies
13-
# requests>=2.28.0 # For HTTP requests
14-
# aiohttp>=3.8.0 # For async HTTP requests
15-
# sqlalchemy>=2.0.0 # For database operations
16-
# pydantic>=2.0.0 # For data validation

0 commit comments

Comments
 (0)