Spaces:
Sleeping
Sleeping
Commit
·
834fcc6
1
Parent(s):
dc39855
Add app
Browse files- Dockerfile +25 -0
- app.py +20 -0
- requirements.txt +1 -0
Dockerfile
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.11
|
2 |
+
|
3 |
+
# Set up a new user named "user" with user ID 1000
|
4 |
+
RUN useradd -m -u 1000 user
|
5 |
+
|
6 |
+
# Switch to the "user" user
|
7 |
+
USER user
|
8 |
+
|
9 |
+
# Set home to the user's home directory
|
10 |
+
ENV HOME=/home/user \
|
11 |
+
PATH=/home/user/.local/bin:$PATH
|
12 |
+
|
13 |
+
COPY --chown=user requirements.txt requirements.txt
|
14 |
+
|
15 |
+
COPY --chown=user app.py app.py
|
16 |
+
|
17 |
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
18 |
+
|
19 |
+
# Upgrade pip
|
20 |
+
# RUN pip install --no-cache-dir --upgrade pip
|
21 |
+
|
22 |
+
# Install requirements
|
23 |
+
RUN uv pip install --no-cache-dir --upgrade -r requirements.txt
|
24 |
+
|
25 |
+
ENTRYPOINT ["solara", "run", "app.py", "--host=0.0.0.0", "--port", "7860"]
|
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import solara
|
2 |
+
|
3 |
+
sentence = solara.reactive("Solara makes our team more productive.")
|
4 |
+
word_limit = solara.reactive(10)
|
5 |
+
@solara.component
|
6 |
+
def Page():
|
7 |
+
solara.Markdown("#Solara Template")
|
8 |
+
# Calculate word_count within the component to ensure re-execution when reactive variables change.
|
9 |
+
word_count = len(sentence.value.split())
|
10 |
+
solara.SliderInt("Word limit", value=word_limit, min=2, max=20)
|
11 |
+
solara.InputText(label="Your sentence", value=sentence, continuous_update=True)
|
12 |
+
# Display messages based on the current word count and word limit.
|
13 |
+
if word_count >= int(word_limit.value):
|
14 |
+
solara.Error(f"With {word_count} words, you passed the word limit of {word_limit.value}.")
|
15 |
+
elif word_count >= int(0.8 * word_limit.value):
|
16 |
+
solara.Warning(f"With {word_count} words, you are close to the word limit of {word_limit.value}.")
|
17 |
+
else:
|
18 |
+
solara.Success("Great short writing!")
|
19 |
+
|
20 |
+
Page()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
solara
|