Spaces:
Sleeping
Sleeping
htmx-indicator
Browse files
app.py
CHANGED
@@ -139,8 +139,7 @@ def query_db(query: str, k: int = 10, reranker: str = "cohere"):
|
|
139 |
# FastHTML app -----
|
140 |
###########################################################################
|
141 |
|
142 |
-
style = Style(
|
143 |
-
"""
|
144 |
:root {
|
145 |
color-scheme: dark;
|
146 |
}
|
@@ -169,8 +168,34 @@ style = Style(
|
|
169 |
white-space: pre-wrap;
|
170 |
word-wrap: break-word;
|
171 |
}
|
172 |
-
|
173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
|
175 |
# get the fast app and route
|
176 |
app, rt = fast_app(live=True, hdrs=(style,))
|
@@ -205,9 +230,15 @@ async def get():
|
|
205 |
query_form = Form(
|
206 |
Textarea(id="query", name="query", placeholder="Enter your query..."),
|
207 |
Button("Submit", type="submit"),
|
|
|
|
|
|
|
|
|
|
|
208 |
id="search-form",
|
209 |
hx_post="/search",
|
210 |
hx_target="#search-results",
|
|
|
211 |
)
|
212 |
|
213 |
# results_div = Div(H2("Search Results"), Div(id="search-results", cls="results-container"))
|
|
|
139 |
# FastHTML app -----
|
140 |
###########################################################################
|
141 |
|
142 |
+
style = Style("""
|
|
|
143 |
:root {
|
144 |
color-scheme: dark;
|
145 |
}
|
|
|
168 |
white-space: pre-wrap;
|
169 |
word-wrap: break-word;
|
170 |
}
|
171 |
+
.htmx-indicator {
|
172 |
+
display: none;
|
173 |
+
}
|
174 |
+
.htmx-request .htmx-indicator {
|
175 |
+
display: inline-block;
|
176 |
+
}
|
177 |
+
.spinner {
|
178 |
+
display: inline-block;
|
179 |
+
width: 2.5em;
|
180 |
+
height: 2.5em;
|
181 |
+
border: 0.3em solid rgba(255,255,255,.3);
|
182 |
+
border-radius: 50%;
|
183 |
+
border-top-color: #fff;
|
184 |
+
animation: spin 1s ease-in-out infinite;
|
185 |
+
margin-left: 10px;
|
186 |
+
vertical-align: middle;
|
187 |
+
}
|
188 |
+
@keyframes spin {
|
189 |
+
to { transform: rotate(360deg); }
|
190 |
+
}
|
191 |
+
.searching-text {
|
192 |
+
font-size: 1.2em;
|
193 |
+
font-weight: bold;
|
194 |
+
color: #fff;
|
195 |
+
margin-right: 10px;
|
196 |
+
vertical-align: middle;
|
197 |
+
}
|
198 |
+
""")
|
199 |
|
200 |
# get the fast app and route
|
201 |
app, rt = fast_app(live=True, hdrs=(style,))
|
|
|
230 |
query_form = Form(
|
231 |
Textarea(id="query", name="query", placeholder="Enter your query..."),
|
232 |
Button("Submit", type="submit"),
|
233 |
+
Div(
|
234 |
+
Span("Searching...", cls="searching-text htmx-indicator"),
|
235 |
+
Span(cls="spinner htmx-indicator"),
|
236 |
+
cls="indicator-container",
|
237 |
+
),
|
238 |
id="search-form",
|
239 |
hx_post="/search",
|
240 |
hx_target="#search-results",
|
241 |
+
hx_indicator=".indicator-container",
|
242 |
)
|
243 |
|
244 |
# results_div = Div(H2("Search Results"), Div(id="search-results", cls="results-container"))
|