Skip to content

Commit a44952d

Browse files
committed
Refactor app
1 parent 26af879 commit a44952d

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

routes_example_app/app.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from fastapi import FastAPI
2-
from shiny import App, ui
2+
from shiny import App, render, ui
33
from starlette.applications import Starlette
44
from starlette.routing import Mount
55

@@ -13,7 +13,21 @@ def index():
1313

1414

1515
# ---
16-
app_shiny = App(ui.page_fluid("hello from shiny!"), None)
16+
shiny_ui = ui.page_fluid(
17+
ui.panel_title("Hello Shiny!"),
18+
ui.input_slider("n", "N", 0, 100, 20),
19+
ui.output_text_verbatim("txt"),
20+
)
21+
22+
23+
def shiny_server(input, output, session):
24+
@render.text
25+
def txt():
26+
print(session.http_conn.headers["host"])
27+
return f"n*2 is {input.n() * 2}"
28+
29+
30+
app_shiny = App(shiny_ui, shiny_server)
1731

1832
# ---
1933
routes = [Mount("/api", app=app_fastapi), Mount("/", app=app_shiny)]

0 commit comments

Comments
 (0)