Spaces:
Sleeping
Sleeping
File size: 1,151 Bytes
aaf306d bb7923c 919e56b 204395e aaf306d bb7923c 204395e bb7923c 204395e bb7923c 846cb56 bb7923c 846cb56 bb7923c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
import subprocess
import gradio as gr
import tempfile
import os
import io
def run_katana(url):
try:
result = subprocess.run(["katana", "-u", url], capture_output=True, text=True, check=True)
# Create an in-memory file-like object
buffer = io.StringIO(result.stdout)
# Generate a filename based on the URL
filename = f"katana_results_{url.replace('://', '_').replace('/', '_')}.txt"
return result.stdout, (buffer, filename)
except Exception as e:
return str(e), None
def process_and_display(url):
result, file_data = run_katana(url)
if file_data:
return result, file_data
else:
return result, None
iface = gr.Interface(
fn=process_and_display,
inputs="text",
outputs=[
gr.Textbox(label="Crawl Results"),
gr.File(label="Download Results", file_count="single")
],
title="Katana Crawler",
description="Enter a URL to crawl using Katana. Results will be displayed and available for download.",
allow_flagging="never"
)
iface.launch(server_name="0.0.0.0", server_port=7860)
|