|
@@ -1,23 +1,27 @@
|
|
|
#!/usr/bin/env python3
|
|
|
-import example_c
|
|
|
-import example_pages
|
|
|
+import api_router_example
|
|
|
+import class_example
|
|
|
+import function_example
|
|
|
import home_page
|
|
|
import theme
|
|
|
|
|
|
from nicegui import app, ui
|
|
|
|
|
|
|
|
|
-# here we use our custom page decorator directly and just put the content creation into a separate function
|
|
|
+# Example 1: use a custom page decorator directly and putting the content creation into a separate function
|
|
|
@ui.page('/')
|
|
|
def index_page() -> None:
|
|
|
with theme.frame('Homepage'):
|
|
|
home_page.content()
|
|
|
|
|
|
|
|
|
-# this call shows that you can also move the whole page creation into a separate file
|
|
|
-example_pages.create()
|
|
|
+# Example 2: use a function to move the whole page creation into a separate file
|
|
|
+function_example.create()
|
|
|
|
|
|
-# we can also use the APIRouter as described in https://nicegui.io/documentation/page#modularize_with_apirouter
|
|
|
-app.include_router(example_c.router)
|
|
|
+# Example 3: use a class to move the whole page creation into a separate file
|
|
|
+class_example.ClassExample()
|
|
|
+
|
|
|
+# Example 4: use APIRouter as described in https://nicegui.io/documentation/page#modularize_with_apirouter
|
|
|
+app.include_router(api_router_example.router)
|
|
|
|
|
|
ui.run(title='Modularization Example')
|