Commit ·
0e037e4
1
Parent(s): f4701aa
simplify
Browse files
app.py
CHANGED
|
@@ -20,28 +20,6 @@ def _load_intro_text() -> str:
|
|
| 20 |
|
| 21 |
INTRO_TEXT = _load_intro_text()
|
| 22 |
|
| 23 |
-
|
| 24 |
-
def _resolve_uploaded_path(file_value: Any) -> str:
|
| 25 |
-
print(f"Resolving uploaded file path from value: {file_value} (type: {type(file_value)})")
|
| 26 |
-
if file_value is None:
|
| 27 |
-
raise ValueError("No file provided")
|
| 28 |
-
|
| 29 |
-
if isinstance(file_value, str):
|
| 30 |
-
return file_value
|
| 31 |
-
|
| 32 |
-
if isinstance(file_value, dict):
|
| 33 |
-
# Gradio may pass FileData-like dicts depending on version/config.
|
| 34 |
-
path = file_value.get("path")
|
| 35 |
-
if isinstance(path, str):
|
| 36 |
-
return path
|
| 37 |
-
|
| 38 |
-
path = getattr(file_value, "name", None)
|
| 39 |
-
if isinstance(path, str):
|
| 40 |
-
return path
|
| 41 |
-
|
| 42 |
-
raise ValueError(f"Unsupported file payload type: {type(file_value)}")
|
| 43 |
-
|
| 44 |
-
|
| 45 |
with gr.Blocks() as demo:
|
| 46 |
intro = gr.Markdown(INTRO_TEXT)
|
| 47 |
|
|
@@ -97,7 +75,6 @@ with gr.Blocks() as demo:
|
|
| 97 |
}
|
| 98 |
|
| 99 |
try:
|
| 100 |
-
# path = _resolve_uploaded_path(file)
|
| 101 |
markdown_value, funs = client.predict(
|
| 102 |
file=handle_file(file),
|
| 103 |
api_name="/file_change_fn",
|
|
@@ -105,8 +82,6 @@ with gr.Blocks() as demo:
|
|
| 105 |
except Exception as e:
|
| 106 |
raise gr.Error(f"Unable to analyze binary with remote app: {e}")
|
| 107 |
|
| 108 |
-
print("Functions:", funs)
|
| 109 |
-
|
| 110 |
return {
|
| 111 |
intro: markdown_value,
|
| 112 |
col: gr.update(visible=True),
|
|
|
|
| 20 |
|
| 21 |
INTRO_TEXT = _load_intro_text()
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
with gr.Blocks() as demo:
|
| 24 |
intro = gr.Markdown(INTRO_TEXT)
|
| 25 |
|
|
|
|
| 75 |
}
|
| 76 |
|
| 77 |
try:
|
|
|
|
| 78 |
markdown_value, funs = client.predict(
|
| 79 |
file=handle_file(file),
|
| 80 |
api_name="/file_change_fn",
|
|
|
|
| 82 |
except Exception as e:
|
| 83 |
raise gr.Error(f"Unable to analyze binary with remote app: {e}")
|
| 84 |
|
|
|
|
|
|
|
| 85 |
return {
|
| 86 |
intro: markdown_value,
|
| 87 |
col: gr.update(visible=True),
|