-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprint.py
73 lines (60 loc) · 2.66 KB
/
print.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import streamlit as st
import json
# Function to read JSON data from the specified path
def read_json(file_path):
try:
with open(file_path, 'r') as f:
data = json.load(f)
return data
except Exception as e:
st.error(f"Error reading JSON file: {e}")
return None
# Function to display the JSON data in Streamlit
def display_data(data):
if data:
st.header(data.get("Place", "Unknown Place"))
st.subheader("Location")
location = data.get("Location", {})
st.write(f"Country: {location.get('Country', 'Unknown')}")
coordinates = location.get("Coordinates", {})
st.write(f"Coordinates: Latitude {coordinates.get('Latitude', 'Unknown')}, Longitude {coordinates.get('Longitude', 'Unknown')}")
st.subheader("History")
st.write(data.get("History", "No history available."))
st.subheader("Ecological Relevance")
st.write(data.get("Ecological Relevance", "No ecological relevance available."))
st.subheader("Cultural Significance")
st.write(data.get("Cultural Significance", "No cultural significance available."))
st.subheader("Key Figures")
key_figures = data.get("Key Figures", [])
if key_figures:
for figure in key_figures:
st.write(f"**{figure.get('Name', 'Unknown')}** - {figure.get('Role', 'Unknown')}")
st.write(f"Contribution: {figure.get('Contribution', 'No contribution details available.')}")
else:
st.write("No key figures available.")
st.subheader("Economic Importance")
st.write(data.get("Economic Importance", "No economic importance available."))
st.subheader("Major Landmarks")
landmarks = data.get("Major Landmarks", [])
if landmarks:
for landmark in landmarks:
st.write(f"**{landmark.get('Name', 'Unknown')}**")
st.write(f"{landmark.get('Description', 'No description available.')}")
else:
st.write("No major landmarks available.")
st.subheader("Timeline of Major Events")
timeline = data.get("Timeline", [])
if timeline:
for event in timeline:
st.write(f"**{event.get('Year', 'Unknown Year')}**: {event.get('Details', 'No details available.')}")
else:
st.write("No major events available.")
else:
st.write("No data to display.")
# Streamlit application
def main():
st.title('Historical Data Viewer')
data = read_json("./data/whitehouse.json")
display_data(data)
if __name__ == "__main__":
main()