Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -151,19 +151,41 @@ with col6:
|
|
151 |
st.button("✒️ Ink")
|
152 |
st.button("📜 Scroll")
|
153 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
def display_images_and_wikipedia_summaries():
|
155 |
st.title('Gallery with Related Stories')
|
156 |
image_files = [f for f in os.listdir('.') if f.endswith('.png')]
|
157 |
if not image_files:
|
158 |
st.write("No PNG images found in the current directory.")
|
159 |
return
|
|
|
160 |
for image_file in image_files:
|
161 |
image = Image.open(image_file)
|
162 |
-
st.image(image, caption=image_file, use_column_width=
|
163 |
-
keyword = image_file.split('.')[0] # Assumes keyword is the file name without extension
|
164 |
|
|
|
165 |
wikipedia_summary = fetch_wikipedia_summary(keyword)
|
166 |
st.write(wikipedia_summary)
|
|
|
|
|
|
|
|
|
|
|
167 |
|
168 |
display_images_and_wikipedia_summaries()
|
169 |
|
|
|
151 |
st.button("✒️ Ink")
|
152 |
st.button("📜 Scroll")
|
153 |
|
154 |
+
|
155 |
+
|
156 |
+
|
157 |
+
def fetch_wikipedia_summary(keyword):
|
158 |
+
# Placeholder function for fetching Wikipedia summaries
|
159 |
+
# In a real app, you might use requests to fetch from the Wikipedia API
|
160 |
+
return f"Summary for {keyword}. For more information, visit Wikipedia."
|
161 |
+
|
162 |
+
def create_search_url_wikipedia(keyword):
|
163 |
+
base_url = "https://www.wikipedia.org/search-redirect.php?family=wikipedia&language=en&search="
|
164 |
+
return base_url + keyword.replace(' ', '+')
|
165 |
+
|
166 |
+
def create_search_url_google(keyword):
|
167 |
+
base_url = "https://www.google.com/search?q="
|
168 |
+
return base_url + keyword.replace(' ', '+')
|
169 |
+
|
170 |
def display_images_and_wikipedia_summaries():
|
171 |
st.title('Gallery with Related Stories')
|
172 |
image_files = [f for f in os.listdir('.') if f.endswith('.png')]
|
173 |
if not image_files:
|
174 |
st.write("No PNG images found in the current directory.")
|
175 |
return
|
176 |
+
|
177 |
for image_file in image_files:
|
178 |
image = Image.open(image_file)
|
179 |
+
st.image(image, caption=image_file, use_column_width=True)
|
|
|
180 |
|
181 |
+
keyword = image_file.split('.')[0] # Assumes keyword is the file name without extension
|
182 |
wikipedia_summary = fetch_wikipedia_summary(keyword)
|
183 |
st.write(wikipedia_summary)
|
184 |
+
|
185 |
+
# Display Wikipedia and Google search links
|
186 |
+
wikipedia_url = create_search_url_wikipedia(keyword)
|
187 |
+
google_url = create_search_url_google(keyword)
|
188 |
+
st.markdown(f"[Wikipedia]({wikipedia_url}) | [Google]({google_url})")
|
189 |
|
190 |
display_images_and_wikipedia_summaries()
|
191 |
|