gordon-posit commited on
Commit
3f928a7
1 Parent(s): 90e8847

Py shiny example

Browse files
Files changed (3) hide show
  1. Dockerfile +13 -0
  2. app.py +26 -0
  3. requirements.txt +0 -0
Dockerfile ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ WORKDIR /code
4
+
5
+ COPY ./requirements.txt /code/requirements.txt
6
+
7
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
+
9
+ COPY . .
10
+
11
+ EXPOSE 7860
12
+
13
+ CMD ["shiny", "run", "app.py", "--host", "0.0.0.0", "--port", "7860"]
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import matplotlib.pyplot as plt
2
+ import numpy as np
3
+ from shiny import App, render, ui
4
+
5
+ app_ui = ui.page_fluid(
6
+ ui.layout_sidebar(
7
+ ui.panel_sidebar(
8
+ ui.input_slider("n", "N", 0, 100, 20),
9
+ ),
10
+ ui.panel_main(
11
+ ui.output_plot("histogram"),
12
+ ),
13
+ ),
14
+ )
15
+
16
+
17
+ def server(input, output, session):
18
+ @output
19
+ @render.plot(alt="A histogram")
20
+ def histogram():
21
+ np.random.seed(19680801)
22
+ x = 100 + 15 * np.random.randn(437)
23
+ plt.hist(x, input.n(), density=True)
24
+
25
+
26
+ app = App(app_ui, server, debug=True)
requirements.txt ADDED
File without changes