Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -18,14 +18,6 @@ def fetch_weather_info(lat, lon):
|
|
18 |
response = requests.get(url)
|
19 |
return response.json()
|
20 |
|
21 |
-
# Data for occupancy
|
22 |
-
occupancy_data = {
|
23 |
-
'Su': [{'hour': 6, 'occupancyPercent': 0}, ...], # truncated for brevity
|
24 |
-
'Mo': [{'hour': 6, 'occupancyPercent': 0}, ...],
|
25 |
-
# ... other days ...
|
26 |
-
'Sa': [{'hour': 6, 'occupancyPercent': 0}, ...]
|
27 |
-
}
|
28 |
-
|
29 |
# Streamlit app
|
30 |
st.title("Data Visualization")
|
31 |
|
@@ -35,6 +27,10 @@ if website_name:
|
|
35 |
google_maps_data = fetch_google_maps_info(website_name)
|
36 |
|
37 |
if google_maps_data:
|
|
|
|
|
|
|
|
|
38 |
# Display location and fetch weather info
|
39 |
lat = google_maps_data["location"]["lat"]
|
40 |
lng = google_maps_data["location"]["lng"]
|
@@ -42,11 +38,12 @@ if website_name:
|
|
42 |
st.map(pd.DataFrame({'lat': [lat], 'lon': [lng]})) # Display the map
|
43 |
weather_data = fetch_weather_info(lat, lng)
|
44 |
current_weather = weather_data.get("current", {})
|
|
|
45 |
st.write(f"**Location:** {lat}, {lng}")
|
46 |
-
st.write(f"**Temperature:** {
|
47 |
st.write(f"**Weather:** {current_weather.get('weather')[0].get('description')}")
|
48 |
|
49 |
-
# Display occupancy chart
|
50 |
st.subheader("Occupancy Data")
|
51 |
df_occupancy = pd.DataFrame()
|
52 |
for day, day_data in occupancy_data.items():
|
|
|
18 |
response = requests.get(url)
|
19 |
return response.json()
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
# Streamlit app
|
22 |
st.title("Data Visualization")
|
23 |
|
|
|
27 |
google_maps_data = fetch_google_maps_info(website_name)
|
28 |
|
29 |
if google_maps_data:
|
30 |
+
# Display website link in a specific output box
|
31 |
+
website_link = google_maps_data.get('website')
|
32 |
+
st.text_area("Website Link:", website_link)
|
33 |
+
|
34 |
# Display location and fetch weather info
|
35 |
lat = google_maps_data["location"]["lat"]
|
36 |
lng = google_maps_data["location"]["lng"]
|
|
|
38 |
st.map(pd.DataFrame({'lat': [lat], 'lon': [lng]})) # Display the map
|
39 |
weather_data = fetch_weather_info(lat, lng)
|
40 |
current_weather = weather_data.get("current", {})
|
41 |
+
temp_in_celsius = current_weather.get('temp') - 273.15
|
42 |
st.write(f"**Location:** {lat}, {lng}")
|
43 |
+
st.write(f"**Temperature:** {temp_in_celsius:.2f}°C")
|
44 |
st.write(f"**Weather:** {current_weather.get('weather')[0].get('description')}")
|
45 |
|
46 |
+
# Display occupancy chart (assuming you provide the correct data in `occupancy_data`)
|
47 |
st.subheader("Occupancy Data")
|
48 |
df_occupancy = pd.DataFrame()
|
49 |
for day, day_data in occupancy_data.items():
|