main.py 776 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env python3
  2. import api_router_example
  3. import class_example
  4. import function_example
  5. import home_page
  6. import theme
  7. from nicegui import app, ui
  8. # Example 1: use a custom page decorator directly and putting the content creation into a separate function
  9. @ui.page('/')
  10. def index_page() -> None:
  11. with theme.frame('Homepage'):
  12. home_page.content()
  13. # Example 2: use a function to move the whole page creation into a separate file
  14. function_example.create()
  15. # Example 3: use a class to move the whole page creation into a separate file
  16. class_example.ClassExample()
  17. # Example 4: use APIRouter as described in https://nicegui.io/documentation/page#modularize_with_apirouter
  18. app.include_router(api_router_example.router)
  19. ui.run(title='Modularization Example')