-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Examples for R moved to subdir. Added basic example for Python.
- Loading branch information
1 parent
3c9106a
commit 401b3ac
Showing
9 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from shiny import App, ui | ||
from shiny_router import route_link, router_ui, route, router_server | ||
|
||
tags = ui.tags | ||
|
||
# This generates menu in user interface with links. | ||
menu = tags.ul( | ||
tags.li(tags.a("Page", class_ = "item", href = route_link("/"))), | ||
tags.li(tags.a("Other page", class_ = "item", href = route_link("other"))), | ||
tags.li(tags.a("A third page", class_ = "item", href = route_link("third"))) | ||
) | ||
|
||
# This creates UI for each page. | ||
def page(title, content): | ||
return tags.div( | ||
menu, | ||
tags.h1(title), | ||
tags.p(content), | ||
) | ||
|
||
# Both sample pages. | ||
root_page = page("Home page", "Welcome on sample routing page!") | ||
other_page = page("Some other page", "Lorem ipsum dolor sit amet.") | ||
third_page = tags.div(menu, tags.h3("Third Page")) | ||
|
||
# Make output for our router in main UI of Shiny app. | ||
app_ui = ui.page_fluid( | ||
router_ui( | ||
route("/", root_page), | ||
route("other", other_page), | ||
route("third", third_page) | ||
) | ||
) | ||
|
||
# Plug router into Shiny server. | ||
def server(input, output, session): | ||
router_server(input, output, session) | ||
|
||
app = App(app_ui, server) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.