Spaces:
Build error
Build error
Commit
•
9dfa832
1
Parent(s):
7beff10
Update app
Browse files
app.py
CHANGED
@@ -1,19 +1,15 @@
|
|
1 |
import solara
|
2 |
|
3 |
-
# Declare reactive variables at the top level. Components using these variables
|
4 |
-
# will be re-executed when their values change.
|
5 |
sentence = solara.reactive("Solara makes our team more productive.")
|
6 |
word_limit = solara.reactive(10)
|
7 |
-
|
8 |
-
|
9 |
@solara.component
|
10 |
def Page():
|
|
|
|
|
11 |
# Calculate word_count within the component to ensure re-execution when reactive variables change.
|
12 |
word_count = len(sentence.value.split())
|
13 |
-
|
14 |
solara.SliderInt("Word limit", value=word_limit, min=2, max=20)
|
15 |
solara.InputText(label="Your sentence", value=sentence, continuous_update=True)
|
16 |
-
|
17 |
# Display messages based on the current word count and word limit.
|
18 |
if word_count >= int(word_limit.value):
|
19 |
solara.Error(f"With {word_count} words, you passed the word limit of {word_limit.value}.")
|
@@ -22,6 +18,4 @@ def Page():
|
|
22 |
else:
|
23 |
solara.Success("Great short writing!")
|
24 |
|
25 |
-
|
26 |
-
# The following line is required only when running the code in a Jupyter notebook:
|
27 |
Page()
|
|
|
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 |
+
solara.Markdown("Remember to add the 'app_port: 7860' to the README.md file")
|
9 |
# Calculate word_count within the component to ensure re-execution when reactive variables change.
|
10 |
word_count = len(sentence.value.split())
|
|
|
11 |
solara.SliderInt("Word limit", value=word_limit, min=2, max=20)
|
12 |
solara.InputText(label="Your sentence", value=sentence, continuous_update=True)
|
|
|
13 |
# Display messages based on the current word count and word limit.
|
14 |
if word_count >= int(word_limit.value):
|
15 |
solara.Error(f"With {word_count} words, you passed the word limit of {word_limit.value}.")
|
|
|
18 |
else:
|
19 |
solara.Success("Great short writing!")
|
20 |
|
|
|
|
|
21 |
Page()
|