Spaces:
Sleeping
Sleeping
import gradio as gr | |
import subprocess | |
import os | |
def run_katana(url): | |
# Set a custom configuration directory | |
katana_config_dir = "/tmp/katana" | |
os.makedirs(katana_config_dir, exist_ok=True) | |
# Set the environment variable for Katana's config directory | |
os.environ["KATANA_CONFIG"] = katana_config_dir | |
output_file = "/tmp/urls.txt" # Use /tmp for writable directory | |
command = f"katana -u {url} > {output_file}" | |
try: | |
subprocess.run(command, shell=True, check=True) | |
return output_file | |
except subprocess.CalledProcessError as e: | |
return f"Error running katana: {e}" | |
# Ensure the /tmp/flagged directory exists | |
os.makedirs("/tmp/flagged", exist_ok=True) | |
# Gradio interface | |
interface = gr.Interface( | |
fn=run_katana, | |
inputs="text", | |
outputs="file", | |
title="Katana URL Crawler", | |
description="Enter a URL to crawl with Katana.", | |
flagging_dir="/tmp/flagged" # Specify a writable directory for flagging | |
) | |
interface.launch(server_name="0.0.0.0", server_port=7860) | |