Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import json
|
3 |
+
|
4 |
+
# 加载 JSON 数据
|
5 |
+
with open("data.json", "r") as file:
|
6 |
+
data = json.load(file)
|
7 |
+
|
8 |
+
# Streamlit 应用
|
9 |
+
st.title("JSON Data Visualization")
|
10 |
+
|
11 |
+
# 遍历数据并显示内容
|
12 |
+
for entry in data:
|
13 |
+
# 解构数据
|
14 |
+
image_name, image_url, description, category = entry
|
15 |
+
|
16 |
+
# 显示图像
|
17 |
+
st.subheader(f"{image_name} - {category}")
|
18 |
+
st.image(image_url, caption=description, use_column_width=True)
|
19 |
+
|
20 |
+
# 显示文本信息
|
21 |
+
st.markdown(f"**Description:** {description}")
|
22 |
+
st.markdown(f"**Category:** {category}")
|
23 |
+
st.markdown("---")
|