Spaces:
Runtime error
Runtime error
Commit
·
3c35ff6
1
Parent(s):
81cc82d
Add Info about README metadata
Browse files
app.py
CHANGED
|
@@ -5,22 +5,24 @@ import solara
|
|
| 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 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
|
| 26 |
# The following line is required only when running the code in a Jupyter notebook:
|
|
|
|
| 5 |
sentence = solara.reactive("Solara makes our team more productive.")
|
| 6 |
word_limit = solara.reactive(10)
|
| 7 |
|
|
|
|
| 8 |
@solara.component
|
| 9 |
def Page():
|
| 10 |
+
with solara.Column(margin=10):
|
| 11 |
+
solara.Markdown("#Solara Template")
|
| 12 |
+
solara.Info("Remember to add the 'app_port: 7860' to the README.md file")
|
| 13 |
+
# Calculate word_count within the component to ensure re-execution when reactive variables change.
|
| 14 |
+
word_count = len(sentence.value.split())
|
| 15 |
+
|
| 16 |
+
solara.SliderInt("Word limit", value=word_limit, min=2, max=20)
|
| 17 |
+
solara.InputText(label="Your sentence", value=sentence, continuous_update=True)
|
| 18 |
+
|
| 19 |
+
# Display messages based on the current word count and word limit.
|
| 20 |
+
if word_count >= int(word_limit.value):
|
| 21 |
+
solara.Error(f"With {word_count} words, you passed the word limit of {word_limit.value}.")
|
| 22 |
+
elif word_count >= int(0.8 * word_limit.value):
|
| 23 |
+
solara.Warning(f"With {word_count} words, you are close to the word limit of {word_limit.value}.")
|
| 24 |
+
else:
|
| 25 |
+
solara.Success("Great short writing!")
|
| 26 |
|
| 27 |
|
| 28 |
# The following line is required only when running the code in a Jupyter notebook:
|