Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,39 +1,63 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
| 2 |
import requests
|
| 3 |
-
from bs4 import BeautifulSoup
|
| 4 |
-
from transformers import pipeline
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
url = f'https://example.com/flights?departure={departure}&arrival={arrival}'
|
| 12 |
response = requests.get(url)
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
# Initialize Streamlit app
|
| 19 |
-
st.title('Flight Timing Travel Application')
|
| 20 |
-
|
| 21 |
-
# User input
|
| 22 |
-
departure = st.text_input('Departure City/Country')
|
| 23 |
-
arrival = st.text_input('Arrival City/Country')
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
processed_departure = model(departure)[0]['label']
|
| 28 |
-
processed_arrival = model(arrival)[0]['label']
|
| 29 |
|
| 30 |
-
#
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
if
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from geopy.distance import geodesic
|
| 3 |
+
import folium
|
| 4 |
+
from streamlit_folium import st_folium
|
| 5 |
import requests
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
# OpenWeatherMap API Key (replace with your own key)
|
| 8 |
+
API_KEY = "your_openweathermap_api_key"
|
| 9 |
|
| 10 |
+
def get_weather(lat, lon):
|
| 11 |
+
url = f"http://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={API_KEY}&units=metric"
|
|
|
|
| 12 |
response = requests.get(url)
|
| 13 |
+
if response.status_code == 200:
|
| 14 |
+
weather_data = response.json()
|
| 15 |
+
return weather_data
|
| 16 |
+
else:
|
| 17 |
+
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
def main():
|
| 20 |
+
st.title("Simplified Flight Planning App")
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
# Flight Planning
|
| 23 |
+
st.header("Flight Planning")
|
| 24 |
+
lat1 = st.number_input("Enter Departure Latitude", value=37.6213) # Example: SFO
|
| 25 |
+
lon1 = st.number_input("Enter Departure Longitude", value=-122.3790)
|
| 26 |
+
lat2 = st.number_input("Enter Destination Latitude", value=34.0522) # Example: LAX
|
| 27 |
+
lon2 = st.number_input("Enter Destination Longitude", value=-118.2437)
|
| 28 |
|
| 29 |
+
if st.button("Calculate Distance"):
|
| 30 |
+
coords_1 = (lat1, lon1)
|
| 31 |
+
coords_2 = (lat2, lon2)
|
| 32 |
+
distance = geodesic(coords_1, coords_2).miles
|
| 33 |
+
st.write(f"Distance: {distance:.2f} miles")
|
| 34 |
+
|
| 35 |
+
# Navigation
|
| 36 |
+
st.header("Navigation")
|
| 37 |
+
m = folium.Map(location=[(lat1 + lat2) / 2, (lon1 + lon2) / 2], zoom_start=6)
|
| 38 |
+
folium.Marker([lat1, lon1], tooltip="Departure").add_to(m)
|
| 39 |
+
folium.Marker([lat2, lon2], tooltip="Destination").add_to(m)
|
| 40 |
+
st_folium(m, width=700)
|
| 41 |
+
|
| 42 |
+
# Weather Updates
|
| 43 |
+
st.header("Weather Updates")
|
| 44 |
+
if st.button("Get Weather Updates"):
|
| 45 |
+
weather_departure = get_weather(lat1, lon1)
|
| 46 |
+
weather_destination = get_weather(lat2, lon2)
|
| 47 |
+
|
| 48 |
+
if weather_departure:
|
| 49 |
+
st.write(f"Weather at Departure: {weather_departure['weather'][0]['description']}")
|
| 50 |
+
st.write(f"Temperature: {weather_departure['main']['temp']}°C")
|
| 51 |
+
st.write(f"Wind Speed: {weather_departure['wind']['speed']} m/s")
|
| 52 |
+
else:
|
| 53 |
+
st.write("Failed to retrieve weather data for departure location.")
|
| 54 |
+
|
| 55 |
+
if weather_destination:
|
| 56 |
+
st.write(f"Weather at Destination: {weather_destination['weather'][0]['description']}")
|
| 57 |
+
st.write(f"Temperature: {weather_destination['main']['temp']}°C")
|
| 58 |
+
st.write(f"Wind Speed: {weather_destination['wind']['speed']} m/s")
|
| 59 |
+
else:
|
| 60 |
+
st.write("Failed to retrieve weather data for destination location.")
|
| 61 |
+
|
| 62 |
+
if __name__ == "__main__":
|
| 63 |
+
main()
|