binuser007007 / app.py
binuser007's picture
Update app.py
bb7923c verified
raw
history blame
1.19 kB
import subprocess
import gradio as gr
import tempfile
import os
def run_katana(url):
try:
# Create a temporary file to store the results
with tempfile.NamedTemporaryFile(mode='w+', delete=False, suffix='.txt') as temp_file:
# Run Katana and save output to the temporary file
subprocess.run(["katana", "-u", url, "-o", temp_file.name], check=True)
# Read the contents of the file
temp_file.seek(0)
result = temp_file.read()
# Return the result and the path to the temporary file
return result, temp_file.name
except Exception as e:
return str(e), None
def process_and_display(url):
result, file_path = run_katana(url)
if file_path:
return result, file_path
else:
return result, None
iface = gr.Interface(
fn=process_and_display,
inputs="text",
outputs=[
gr.Textbox(label="Crawl Results"),
gr.File(label="Download Results")
],
title="Katana Crawler",
description="Enter a URL to crawl using Katana. Results will be displayed and available for download."
)
iface.launch(server_name="0.0.0.0", server_port=7860)