Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic routing #11

Closed
Daxexs opened this issue Apr 12, 2024 · 0 comments
Closed

Automatic routing #11

Daxexs opened this issue Apr 12, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@Daxexs
Copy link
Owner

Daxexs commented Apr 12, 2024

It simplifies the imports by .py files of the pages, the use is similar to the other forms of routing by FletEasy, since the AddPagesy class is used in files other than main.py.

Example of structure:

Image

In the file ìndex.py:

import flet as ft
import flet_easy as fs

# We add a page
index = fs.AddPagesy()


@index.page(route="/home", title="Flet-Easy")
async def index_page(data: fs.Datasy):
    return ft.View(
        controls=[
            ft.Text("Home page"),
        ],
        vertical_alignment=ft.MainAxisAlignment.CENTER,
        horizontal_alignment=ft.CrossAxisAlignment.CENTER,
    )

In the main.py file it should be:

from pathlib import Path

import flet_easy as fs

app = fs.FletEasy(
    route_init="/home",
    path_view=Path(__file__).parent / "views",
)

# We run the application
app.run()

Note: The folder name can be anything, just add a correct path.

@Daxexs Daxexs added the enhancement New feature or request label Apr 12, 2024
@Daxexs Daxexs self-assigned this Apr 12, 2024
@Daxexs Daxexs moved this to In progress in Flet-Easy Development Apr 12, 2024
Daxexs added a commit that referenced this issue Apr 12, 2024
@Daxexs Daxexs moved this from In progress to Ready in Flet-Easy Development Apr 19, 2024
@Daxexs Daxexs moved this from Ready to In review in Flet-Easy Development Apr 19, 2024
@Daxexs Daxexs mentioned this issue Apr 20, 2024
@Daxexs Daxexs closed this as completed Apr 21, 2024
@github-project-automation github-project-automation bot moved this from In review to Done in Flet-Easy Development Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

1 participant