Spaces:
Build error
Build error
Effah Kofi Boakye Yiadom
commited on
Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from summarize import load_text, summarize_text
|
| 3 |
+
|
| 4 |
+
# Streamlit app
|
| 5 |
+
st.title("Text Summarizer with Hugging Face")
|
| 6 |
+
|
| 7 |
+
# User input for URL
|
| 8 |
+
url = st.text_input("Enter the URL of the article or blog post:")
|
| 9 |
+
|
| 10 |
+
if st.button("Summarize"):
|
| 11 |
+
if url:
|
| 12 |
+
text = load_text(url)
|
| 13 |
+
if text:
|
| 14 |
+
summary = summarize_text(text)
|
| 15 |
+
st.subheader("Summary:")
|
| 16 |
+
st.write(summary["output_text"])
|
| 17 |
+
else:
|
| 18 |
+
st.error("Failed to load text from the URL.")
|
| 19 |
+
else:
|
| 20 |
+
st.error("Please enter a valid URL.")
|