ソースを参照

add documentation for app.urls

Rodja Trappe 1 年間 前
コミット
79746fc5d8
1 ファイル変更15 行追加0 行削除
  1. 15 0
      website/documentation.py

+ 15 - 0
website/documentation.py

@@ -531,6 +531,21 @@ def create_full() -> None:
         ui.button('shutdown', on_click=lambda: ui.notify(
             'Nah. We do not actually shutdown the documentation server. Try it in your own app!'))
 
+    @text_demo('Urls', '''
+        You can access the list of all urls on which the NiceGUI app is available via `app.urls`.
+        The urls are not available in `app.on_startup` because the server is not yet running.
+        Instead, you can access them in a page function or register a callback with `app.urls.on_change`.
+        ''')
+    def urls_demo():
+        from nicegui import app
+
+        # @ui.page('/')
+        # def index():
+        #     for url in app.urls:
+        #         ui.link(url, target=url)
+        # END OF DEMO
+        ui.link('https://nicegui.io', target='https://nicegui.io')
+
     heading('NiceGUI Fundamentals')
 
     @text_demo('Auto-context', '''