SaiKumar1627 commited on
Commit
bbcec74
·
verified ·
1 Parent(s): 03d8758

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -15
app.py CHANGED
@@ -1,13 +1,40 @@
1
  import gradio as gr
2
  import pandas as pd
3
- from deliverable2 import URLValidator # Ensure this file exists in the same directory
4
 
5
  # Instantiate Validator
6
  validator = URLValidator()
7
 
8
- # Define function for Gradio UI
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  def validate_url(user_query, url_to_check):
10
- """ Validate URL credibility based on user query. """
11
  result = validator.rate_url_validity(user_query, url_to_check)
12
  return {
13
  "Domain Trust": result["raw_score"]["Domain Trust"],
@@ -21,17 +48,21 @@ def validate_url(user_query, url_to_check):
21
  }
22
 
23
  # Create Gradio Interface
24
- iface = gr.Interface(
25
- fn=validate_url,
26
- inputs=[
27
- gr.Textbox(label="Enter Your Search Query"),
28
- gr.Textbox(label="Enter the URL to Check")
29
- ],
30
- outputs="json",
31
- title="URL Credibility Checker",
32
- description="Enter a query and a URL to check its credibility.",
33
- )
34
 
35
- # Launch Gradio App
36
- iface.launch()
 
 
37
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  import pandas as pd
3
+ from deliverable2 import URLValidator # Ensure this file exists
4
 
5
  # Instantiate Validator
6
  validator = URLValidator()
7
 
8
+ # Add Your Own Queries
9
+ sample_queries = [
10
+ "How does climate change impact global weather?",
11
+ "What are the latest advancements in AI?",
12
+ "How does diet influence mental health?",
13
+ "What are the effects of space travel on astronauts?",
14
+ "Is cryptocurrency a safe investment?",
15
+ "What are the advantages of renewable energy?",
16
+ "How does deep learning work?",
17
+ "What are the health risks of 5G technology?",
18
+ "Is intermittent fasting effective for weight loss?",
19
+ "How do electric vehicles compare to gas cars?"
20
+ ]
21
+
22
+ # ✅ Add Your Own URLs
23
+ sample_urls = [
24
+ "https://www.nationalgeographic.com/environment/article/climate-change",
25
+ "https://www.technologyreview.com/2023/05/01/latest-ai-advancements/",
26
+ "https://www.health.harvard.edu/mind-and-mood/foods-linked-to-better-brainpower",
27
+ "https://www.nasa.gov/hrp/long-term-health-risks-of-space-travel",
28
+ "https://www.investopedia.com/terms/c/cryptocurrency.asp",
29
+ "https://www.energy.gov/eere/renewable-energy",
30
+ "https://www.ibm.com/cloud/deep-learning",
31
+ "https://www.who.int/news-room/questions-and-answers/item/radiation-5g-mobile-networks-and-health",
32
+ "https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6167940/",
33
+ "https://www.tesla.com/blog/benefits-of-electric-vehicles"
34
+ ]
35
+
36
+ # Function to validate URLs
37
  def validate_url(user_query, url_to_check):
 
38
  result = validator.rate_url_validity(user_query, url_to_check)
39
  return {
40
  "Domain Trust": result["raw_score"]["Domain Trust"],
 
48
  }
49
 
50
  # Create Gradio Interface
51
+ with gr.Blocks() as app:
52
+ gr.Markdown("## 🌍 URL Credibility Validator")
53
+ gr.Markdown("### Validate the credibility of any webpage using AI")
 
 
 
 
 
 
 
54
 
55
+ user_query = gr.Dropdown(sample_queries, label="Select a search query:")
56
+ url_to_check = gr.Dropdown(sample_urls, label="Select a URL to validate:")
57
+
58
+ validation_result = gr.Textbox(label="Validation Results", interactive=False)
59
 
60
+ validate_button = gr.Button("Validate URL")
61
+
62
+ def process(user_query, url_to_check):
63
+ return validate_url(user_query, url_to_check)
64
+
65
+ validate_button.click(fn=process, inputs=[user_query, url_to_check], outputs=validation_result)
66
+
67
+ # Launch Gradio App
68
+ app.launch()