adithya747 commited on
Commit
c0d7d7d
·
verified ·
1 Parent(s): 228d559

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -7,10 +7,16 @@ def summarize_website(url):
7
  response = requests.get(url)
8
  soup = BeautifulSoup(response.text, "html.parser")
9
  paragraphs = soup.find_all("p")
10
- text = " ".join([p.get_text() for p in paragraphs[:5]])
11
- return text if text else "No content found."
 
 
 
 
 
 
12
  except Exception as e:
13
- return f"Error: {str(e)}"
14
 
15
- iface = gr.Interface(fn=summarize_website, inputs="text", outputs="text", title="Website Summarizer")
16
  iface.launch()
 
7
  response = requests.get(url)
8
  soup = BeautifulSoup(response.text, "html.parser")
9
  paragraphs = soup.find_all("p")
10
+
11
+ # Extract more content (e.g., first 10 paragraphs)
12
+ text = "\n\n".join([p.get_text() for p in paragraphs[:10]])
13
+
14
+ # Format text as Markdown
15
+ markdown_summary = f"## Website Summary\n\n{text}" if text else "No content found."
16
+
17
+ return markdown_summary
18
  except Exception as e:
19
+ return f"**Error:** {str(e)}"
20
 
21
+ iface = gr.Interface(fn=summarize_website, inputs="text", outputs=gr.Markdown(), title="Website Summarizer")
22
  iface.launch()