Adds basic module structure

This commit is contained in:
procrastimax 2023-06-17 16:42:37 +02:00
parent 93ecad3223
commit e030b7d36d
2 changed files with 24 additions and 8 deletions

12
app.py
View File

@ -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(
ui.h2("Hello Shiny!"),
ui.input_slider("n", "N", 0, 100, 20),
ui.output_text_verbatim("txt"),
mod_welcome.welcome_ui("welcome"),
)
def server(input, output, session):
@output
@render.text
def txt():
return f"n*2 is {input.n() * 2}"
mod_welcome.welcome_server()
app = App(app_ui, server)

20
src/mod_welcome.py Normal file
View 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