Adds basic module structure
This commit is contained in:
parent
93ecad3223
commit
e030b7d36d
2 changed files with 24 additions and 8 deletions
12
app.py
12
app.py
|
@ -1,17 +1,13 @@
|
||||||
from shiny import App, render, ui
|
from shiny import App, ui
|
||||||
|
from src import mod_welcome
|
||||||
|
|
||||||
app_ui = ui.page_fluid(
|
app_ui = ui.page_fluid(
|
||||||
ui.h2("Hello Shiny!"),
|
mod_welcome.welcome_ui("welcome"),
|
||||||
ui.input_slider("n", "N", 0, 100, 20),
|
|
||||||
ui.output_text_verbatim("txt"),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def server(input, output, session):
|
def server(input, output, session):
|
||||||
@output
|
mod_welcome.welcome_server()
|
||||||
@render.text
|
|
||||||
def txt():
|
|
||||||
return f"n*2 is {input.n() * 2}"
|
|
||||||
|
|
||||||
|
|
||||||
app = App(app_ui, server)
|
app = App(app_ui, server)
|
||||||
|
|
20
src/mod_welcome.py
Normal file
20
src/mod_welcome.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
from shiny import module, ui
|
||||||
|
|
||||||
|
# UI ----
|
||||||
|
# Note that we made conter_ui a function, and decorated it
|
||||||
|
|
||||||
|
|
||||||
|
@module.ui
|
||||||
|
def welcome_ui():
|
||||||
|
return ui.div(
|
||||||
|
{"style": "border: 1px solid #ccc; border-radius: 5px; margin: 5px 0;"},
|
||||||
|
ui.h2("Das ist die Welcome Page"),
|
||||||
|
ui.markdown("""Hallo Welt""")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Server ----
|
||||||
|
# Note that we just added the @module.server decorator
|
||||||
|
@module.server
|
||||||
|
def welcome_server(input, output, session, starting_value=0):
|
||||||
|
pass
|
Loading…
Reference in a new issue