njain commited on
Commit
12d4c73
·
1 Parent(s): 7a2a0e0

Upload 3 files

Browse files
Files changed (3) hide show
  1. Dockerfile +2 -2
  2. app.py +15 -12
  3. requirements.txt +1 -1
Dockerfile CHANGED
@@ -1,6 +1,6 @@
1
- FROM python:3.9
2
  WORKDIR /code
3
  COPY ./requirements.txt /code/requirements.txt
4
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
5
  COPY . .
6
- CMD ["python", "/code/app.py", "--host", "nikhilj-Webpanel.hf.space", "--port", "7860"]
 
1
+ FROM python:3.8
2
  WORKDIR /code
3
  COPY ./requirements.txt /code/requirements.txt
4
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
5
  COPY . .
6
+ CMD ["panel", "serve", "/code/app.py", "--host", "nikhilj-Webpanel.hf.space", "--port", "7860"]
app.py CHANGED
@@ -1,17 +1,20 @@
1
  import panel as pn
2
 
3
- # Create a list of numbers
4
  numbers = [1, 2, 3, 4, 5]
5
 
6
- # Create a Panel app
7
- app = pn.Column(
8
- pn.Row(
9
- pn.Text("Numbers"),
10
- pn.Select(options=numbers, value=numbers[0]),
11
- ),
12
- pn.Button("Add Number", click=lambda: numbers.append(numbers[-1] + 1)),
13
- pn.Table(numbers),
14
- )
15
 
16
- # Serve the app
17
- app.servable()
 
 
 
 
 
 
 
 
 
 
 
1
  import panel as pn
2
 
 
3
  numbers = [1, 2, 3, 4, 5]
4
 
5
+ def square_numbers():
6
+ squared = [num ** 2 for num in numbers]
7
+ return squared
 
 
 
 
 
 
8
 
9
+ pn.extension()
10
+
11
+ button = pn.widgets.Button(name='Square Numbers', button_type='primary')
12
+ output = pn.widgets.StaticText()
13
+
14
+ def button_click(event):
15
+ output.value = str(square_numbers())
16
+
17
+ button.on_click(button_click)
18
+
19
+ app = pn.Column(button, output)
20
+ app.servable()
requirements.txt CHANGED
@@ -1 +1 @@
1
- panel
 
1
+ panel==0.12.1