Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,26 +2,28 @@ import subprocess
|
|
2 |
import gradio as gr
|
3 |
import tempfile
|
4 |
import os
|
5 |
-
|
6 |
|
7 |
def run_katana(url):
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
19 |
return str(e), None
|
20 |
|
21 |
def process_and_display(url):
|
22 |
-
result,
|
23 |
-
if
|
24 |
-
return result,
|
25 |
else:
|
26 |
return result, None
|
27 |
|
|
|
2 |
import gradio as gr
|
3 |
import tempfile
|
4 |
import os
|
5 |
+
|
6 |
|
7 |
def run_katana(url):
|
8 |
+
try:
|
9 |
+
# Create a temporary file to store the results
|
10 |
+
with tempfile.NamedTemporaryFile(mode='w+', delete=False, suffix='.txt') as temp_file:
|
11 |
+
# Run Katana and save output to the temporary file
|
12 |
+
subprocess.run(["katana", "-u", url, "-o", temp_file.name], check=True)
|
13 |
+
|
14 |
+
# Read the contents of the file
|
15 |
+
temp_file.seek(0)
|
16 |
+
result = temp_file.read()
|
17 |
+
|
18 |
+
# Return the result and the path to the temporary file
|
19 |
+
return result, temp_file.name
|
20 |
+
except Exception as e:
|
21 |
return str(e), None
|
22 |
|
23 |
def process_and_display(url):
|
24 |
+
result, file_path = run_katana(url)
|
25 |
+
if file_path:
|
26 |
+
return result, file_path
|
27 |
else:
|
28 |
return result, None
|
29 |
|