Spaces:
Sleeping
Sleeping
Merge branch 'main' into abby_api_updates
Browse files- main.py +39 -21
- requirements.txt +1 -1
main.py
CHANGED
|
@@ -1,6 +1,16 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import met_api
|
| 3 |
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
# Page setup
|
| 5 |
st.set_page_config(page_title="The METrics", layout="centered")
|
| 6 |
|
|
@@ -34,31 +44,39 @@ st.markdown(
|
|
| 34 |
unsafe_allow_html=True
|
| 35 |
)
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
with
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
st.write("")
|
| 57 |
st.write("")
|
| 58 |
# Search bar
|
| 59 |
st.markdown("""
|
| 60 |
<div style='display: flex; justify-content: center;'>
|
| 61 |
-
<input type="text" placeholder=" 🔎 Search Met's Art Collection...."
|
| 62 |
style="padding: 10px; width: 250px; border-radius: 20px; border: 1px solid #ccc;">
|
| 63 |
</div>
|
| 64 |
""", unsafe_allow_html=True)
|
|
@@ -87,7 +105,7 @@ st.write("")
|
|
| 87 |
# Footer
|
| 88 |
st.markdown("""
|
| 89 |
<div style='position: fixed; bottom: 10px; left: 0; right: 0; text-align: center; font-size: 12px;'>
|
| 90 |
-
<span style="font-size: 14px;">ℹ️ Met API and data related information is available at –
|
| 91 |
<a href="https://metmuseum.github.io/" target="_blank">https://metmuseum.github.io/</a></span>
|
| 92 |
</div>
|
| 93 |
""", unsafe_allow_html=True)
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
+
from met_api import get_objectsWithImages, get_images
|
| 4 |
+
|
| 5 |
+
# Caching Section
|
| 6 |
+
@st.cache_data
|
| 7 |
+
def cache_objectsWithImages():
|
| 8 |
+
return get_objectsWithImages()
|
| 9 |
+
|
| 10 |
+
@st.cache_data
|
| 11 |
+
def cache_images(total, objectIDs, limit):
|
| 12 |
+
return get_images(total, objectIDs, limit)
|
| 13 |
+
|
| 14 |
# Page setup
|
| 15 |
st.set_page_config(page_title="The METrics", layout="centered")
|
| 16 |
|
|
|
|
| 44 |
unsafe_allow_html=True
|
| 45 |
)
|
| 46 |
|
| 47 |
+
total, ids = cache_objectsWithImages()
|
| 48 |
+
images = cache_images(total, ids, limit=3)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
if images:
|
| 52 |
+
# Columns with fixed-height images
|
| 53 |
+
col1, col2, col3 = st.columns(3)
|
| 54 |
+
|
| 55 |
+
with col1:
|
| 56 |
+
st.markdown(
|
| 57 |
+
f"<div class='img-box'><img src='{images[0][0]}'></div>",
|
| 58 |
+
unsafe_allow_html=True
|
| 59 |
+
)
|
| 60 |
+
st.markdown(f"<div>{images[0][1]}</div>", unsafe_allow_html=True)
|
| 61 |
+
with col2:
|
| 62 |
+
st.markdown(
|
| 63 |
+
f"<div class='img-box'><img src='{images[1][0]}'></div>",
|
| 64 |
+
unsafe_allow_html=True
|
| 65 |
+
)
|
| 66 |
+
st.markdown(f"<div>{images[1][1]}</div>", unsafe_allow_html=True)
|
| 67 |
+
with col3:
|
| 68 |
+
st.markdown(
|
| 69 |
+
f"<div class='img-box'><img src='{images[2][0]}'></div>",
|
| 70 |
+
unsafe_allow_html=True
|
| 71 |
+
)
|
| 72 |
+
st.markdown(f"<div>{images[2][1]}</div>", unsafe_allow_html=True)
|
| 73 |
|
| 74 |
st.write("")
|
| 75 |
st.write("")
|
| 76 |
# Search bar
|
| 77 |
st.markdown("""
|
| 78 |
<div style='display: flex; justify-content: center;'>
|
| 79 |
+
<input type="text" placeholder=" 🔎 Search Met's Art Collection...."
|
| 80 |
style="padding: 10px; width: 250px; border-radius: 20px; border: 1px solid #ccc;">
|
| 81 |
</div>
|
| 82 |
""", unsafe_allow_html=True)
|
|
|
|
| 105 |
# Footer
|
| 106 |
st.markdown("""
|
| 107 |
<div style='position: fixed; bottom: 10px; left: 0; right: 0; text-align: center; font-size: 12px;'>
|
| 108 |
+
<span style="font-size: 14px;">ℹ️ Met API and data related information is available at –
|
| 109 |
<a href="https://metmuseum.github.io/" target="_blank">https://metmuseum.github.io/</a></span>
|
| 110 |
</div>
|
| 111 |
""", unsafe_allow_html=True)
|
requirements.txt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
streamlit==1.48.1
|
| 2 |
pandas
|
| 3 |
-
requests
|
|
|
|
| 1 |
streamlit==1.48.1
|
| 2 |
pandas
|
| 3 |
+
requests==2.32.5
|