{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# URLs\n", "\n", "您可以通过 app.urls 访问 NiceGUI 应用程序可用的所有 URL 列表。由于服务器尚未运行,因此在 `app.on_startup` 中无法访问这些 URL。相反,您可以在页面函数中访问它们,或者使用 `app.urls.on_change` 注册回调函数。" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from nicegui import app, ui\n", "\n", "@ui.page('/')\n", "def index():\n", " for url in app.urls:\n", " ui.link(url, target=url)\n", "\n", "# ui.run()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "py311", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.7" } }, "nbformat": 4, "nbformat_minor": 2 }