File size: 1,240 Bytes
aaf306d
bb7923c
 
919e56b
e71a6e3
aaf306d
bb7923c
e71a6e3
 
 
 
 
 
 
 
 
 
 
 
 
bb7923c
 
 
e71a6e3
 
 
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
42
43
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", 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)