Spaces:
Sleeping
Sleeping
alrichardbollans commited on
Commit ·
0e9299b
1
Parent(s): 18a5290
Revert fix downloads without results
Browse files
app.py
CHANGED
|
@@ -217,25 +217,23 @@ def server(input, output, session: Session):
|
|
| 217 |
|
| 218 |
return ui.div(ui_output)
|
| 219 |
|
| 220 |
-
@
|
| 221 |
def download():
|
| 222 |
results = analysis_results.get()
|
| 223 |
-
if not results:
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
df.to_csv(tmp.name, index=False)
|
| 238 |
-
return tmp.name
|
| 239 |
|
| 240 |
|
| 241 |
app = App(app_ui, server)
|
|
|
|
| 217 |
|
| 218 |
return ui.div(ui_output)
|
| 219 |
|
| 220 |
+
@render.download()
|
| 221 |
def download():
|
| 222 |
results = analysis_results.get()
|
| 223 |
+
# if not results:
|
| 224 |
+
# None
|
| 225 |
+
df = pd.DataFrame([{
|
| 226 |
+
"Filename": r["filename"],
|
| 227 |
+
"Viable": r.get("viable", ""),
|
| 228 |
+
"Non-Viable": r.get("non-viable", ""),
|
| 229 |
+
"Empty": r.get("empty", ""),
|
| 230 |
+
"Total": r.get("total", "")
|
| 231 |
+
} for r in results])
|
| 232 |
+
|
| 233 |
+
# Create in-memory CSV file
|
| 234 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".csv") as tmp:
|
| 235 |
+
df.to_csv(tmp.name, index=False)
|
| 236 |
+
return tmp.name
|
|
|
|
|
|
|
| 237 |
|
| 238 |
|
| 239 |
app = App(app_ui, server)
|