Update app.py
Browse files
app.py
CHANGED
@@ -3,13 +3,30 @@ import os
|
|
3 |
import glob
|
4 |
import zipfile
|
5 |
|
6 |
-
def extract_zip(zip_path, extract_to="
|
7 |
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
8 |
zip_ref.extractall(extract_to)
|
9 |
return extract_to
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
def main():
|
12 |
-
st.title('Zip File
|
13 |
|
14 |
# Check for zip files in the current directory
|
15 |
zip_files = glob.glob('*.zip')
|
@@ -25,10 +42,16 @@ def main():
|
|
25 |
st.success(f'Extracted to {extract_path}')
|
26 |
|
27 |
# Display video gallery
|
28 |
-
videos = glob.glob(f'{extract_path}/*.mp4')
|
29 |
-
for video in videos:
|
30 |
-
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
else:
|
33 |
st.write("No zip files found in the directory.")
|
34 |
|
|
|
3 |
import glob
|
4 |
import zipfile
|
5 |
|
6 |
+
def extract_zip(zip_path, extract_to="extracted_images"):
|
7 |
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
8 |
zip_ref.extractall(extract_to)
|
9 |
return extract_to
|
10 |
|
11 |
+
search_urls = {
|
12 |
+
"๐": lambda k: f"https://en.wikipedia.org/wiki/{quote(k)}",
|
13 |
+
"๐": lambda k: f"https://www.google.com/search?q={quote(k)}",
|
14 |
+
"โถ๏ธ": lambda k: f"https://www.youtube.com/results?search_query={quote(k)}",
|
15 |
+
"๐": lambda k: f"https://www.bing.com/search?q={quote(k)}",
|
16 |
+
"๐ฒ": lambda k: f"https://huggingface.co/spaces/awacke1/AI-ChatGPT-CPT-Body-Map-Cost?q={quote(k)}",
|
17 |
+
}
|
18 |
+
|
19 |
+
def generate_search_links(filename):
|
20 |
+
# Remove the file extension and replace underscores with spaces for search terms
|
21 |
+
search_term = filename.rsplit('.', 1)[0].replace("_", " ")
|
22 |
+
# Generate markdown links for each search URL
|
23 |
+
links_md = ' '.join([f"[{emoji}]({url(search_term)})" for emoji, url in search_urls.items()])
|
24 |
+
# Display the markdown with Streamlit
|
25 |
+
st.markdown(f"Explore **{search_term}** in: {links_md}", unsafe_allow_html=True)
|
26 |
+
|
27 |
+
|
28 |
def main():
|
29 |
+
st.title('Zip File Image Gallery')
|
30 |
|
31 |
# Check for zip files in the current directory
|
32 |
zip_files = glob.glob('*.zip')
|
|
|
42 |
st.success(f'Extracted to {extract_path}')
|
43 |
|
44 |
# Display video gallery
|
45 |
+
#videos = glob.glob(f'{extract_path}/*.mp4')
|
46 |
+
#for video in videos:
|
47 |
+
# st.video(video, format="video/mp4", start_time=0)
|
48 |
|
49 |
+
# Display image gallery
|
50 |
+
images = glob.glob(f'{extract_path}/*.png') # Adjusted to include all image file types
|
51 |
+
for image in images:
|
52 |
+
st.image(image, caption=os.path.basename(image), width=300)
|
53 |
+
generate_search_links(os.path.basename(image))
|
54 |
+
|
55 |
else:
|
56 |
st.write("No zip files found in the directory.")
|
57 |
|