Inam65 commited on
Commit
ea3ff10
·
verified ·
1 Parent(s): f42c064

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from streamlit_folium import st_folium
3
+ import folium
4
+ import requests
5
+ from datetime import datetime
6
+ import cdsapi # To connect with ECMWF's Copernicus Data Service
7
+
8
+ # Streamlit App
9
+ st.title("Weather Explorer 🌍☀️")
10
+
11
+ st.markdown("Search and click a location on the map to get current and historical temperature data.")
12
+
13
+ # Map setup
14
+ m = folium.Map(location=[20, 0], zoom_start=2)
15
+ map_data = st_folium(m, width=700, height=500)
16
+
17
+ # Check if user clicked a location
18
+ if map_data and map_data.get("last_clicked"):
19
+ lat = map_data["last_clicked"]["lat"]
20
+ lon = map_data["last_clicked"]["lng"]
21
+ st.success(f"You selected: Latitude {lat:.4f}, Longitude {lon:.4f}")
22
+
23
+ # Get today's date
24
+ today = datetime.utcnow().date()
25
+
26
+ # --------- Replace below with actual data fetching ----------
27
+ st.write("Fetching current and historical weather data...")
28
+
29
+ # Example placeholder (you'll replace this with real ECMWF data):
30
+ current_temp = 25 # Placeholder: current temperature
31
+ historical_min_temp = 15 # Placeholder: historical minimum
32
+ historical_max_temp = 35 # Placeholder: historical maximum
33
+
34
+ st.metric("Current Temperature (°C)", f"{current_temp}°C")
35
+ st.metric("Historical Min (°C) on this day", f"{historical_min_temp}°C")
36
+ st.metric("Historical Max (°C) on this day", f"{historical_max_temp}°C")