awacke1 commited on
Commit
93bff19
โ€ข
1 Parent(s): e06da02

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -0
app.py CHANGED
@@ -1,3 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  st.markdown('# Three Dragons ๐Ÿ‰๐ŸŒ Mythical Dragons Around the World by Aaron Wacker')
3
 
 
1
+ import streamlit as st
2
+ import os
3
+ from PIL import Image
4
+
5
+ # Placeholder function for Wikipedia content fetching
6
+ # You'll need to replace this with actual fetching logic
7
+ def fetch_wikipedia_summary(keyword):
8
+ # Placeholder text, replace with actual Wikipedia fetching logic
9
+ return f"Summary about {keyword} from Wikipedia."
10
+
11
+ # Display images from the current directory and fetch related Wikipedia stories
12
+ def display_images_and_wikipedia_summaries():
13
+ st.title('Gallery with Related Stories')
14
+
15
+ # Scan current directory for PNG images
16
+ image_files = [f for f in os.listdir('.') if f.endswith('.png')]
17
+
18
+ # Check if there are any PNG images
19
+ if not image_files:
20
+ st.write("No PNG images found in the current directory.")
21
+ return
22
+
23
+ # Iterate over found images
24
+ for image_file in image_files:
25
+ # Open and display each image
26
+ image = Image.open(image_file)
27
+ st.image(image, caption=image_file, use_column_width='always')
28
+
29
+ # Extract a keyword from the image file name for Wikipedia search
30
+ # This is a simple example; adjust logic as needed for more complex titles
31
+ keyword = image_file.split('.')[0] # Assumes keyword is the file name without extension
32
+
33
+ # Fetch and display related Wikipedia content
34
+ wikipedia_summary = fetch_wikipedia_summary(keyword)
35
+ st.write(wikipedia_summary)
36
+
37
+ # Call the function to display images and summaries
38
+ display_images_and_wikipedia_summaries()
39
+
40
+
41
+
42
  import streamlit as st
43
  st.markdown('# Three Dragons ๐Ÿ‰๐ŸŒ Mythical Dragons Around the World by Aaron Wacker')
44