File size: 1,436 Bytes
8f885c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from src.evaluator import website_analyzer, pdf_analyzer

with gr.Blocks(theme=gr.themes.Soft(), css="style.css") as demo:
    with gr.Tab("Website Analyzer"):
        with gr.Row():
            with gr.Column():
                website_input = gr.Textbox(label="Website URL")
            with gr.Column():
                website_output = gr.Image(label="Safety Score")
        analyze_website_btn = gr.Button("Analyze Website")
        analyze_website_btn.click(
            fn=website_analyzer,
            inputs=website_input,
            outputs=website_output,
        )

        examples = ["https://www.nytimes.com/", "https://www.bbc.com/news", "https://www.theguardian.com/international", "https://www.reuters.com", "https://www.aljazeera.com"]

        gr.Examples(
            examples=examples,
            inputs=website_input,
        )

    with gr.Tab("Document Analyzer"):
        with gr.Row():
            with gr.Column():
                document_input = gr.File(label="Upload PDF Document", file_types=[".pdf"])
            with gr.Column():
                document_output = gr.Image(label="Safety Score")
        analyze_document_btn = gr.Button("Analyze Document")
        analyze_document_btn.click(
            fn=pdf_analyzer,  
            inputs=document_input,
            outputs=document_output,
        )

if __name__ == "__main__":
    demo.queue(max_size=10).launch(debug=True)