Mavhas commited on
Commit
4e72d1b
·
verified ·
1 Parent(s): 081034a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -7
app.py CHANGED
@@ -5,22 +5,55 @@ import os
5
  st.set_page_config(page_title="Aircraft Information App", page_icon=":airplane:", layout="wide")
6
 
7
  try:
8
- aircraft_data = pd.read_csv("aircraft_data.csv") # Reads the CSV
9
  except FileNotFoundError:
10
  st.error("aircraft_data.csv not found. Please upload the data file.")
11
  st.stop()
12
 
13
- # ... (rest of your Streamlit code - same as before)
14
 
15
- # Improved Image Display Handling (Robust for Hugging Face and Local)
16
- image_path = aircraft_info["Image URL"] # Gets the path from the CSV
17
 
18
- if os.path.exists(image_path): # Checks if it's a local file
 
 
 
 
 
 
 
 
19
  st.image(image_path, use_column_width=True, caption=aircraft_info["Aircraft Name"])
20
- else: # If not a local file, try as a URL
21
  try:
22
  st.image(image_path, use_column_width=True, caption=aircraft_info["Aircraft Name"])
23
  except Exception as e:
24
  st.error(f"Error displaying image: {e}. Check the URL/path in the CSV.")
25
 
26
- # ... (rest of your Streamlit code)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  st.set_page_config(page_title="Aircraft Information App", page_icon=":airplane:", layout="wide")
6
 
7
  try:
8
+ aircraft_data = pd.read_csv("aircraft_data.csv")
9
  except FileNotFoundError:
10
  st.error("aircraft_data.csv not found. Please upload the data file.")
11
  st.stop()
12
 
13
+ st.title("Aircraft Information App")
14
 
15
+ aircraft_names = aircraft_data["Aircraft Name"].unique()
16
+ selected_aircraft = st.selectbox("Select an Aircraft", aircraft_names)
17
 
18
+ if selected_aircraft:
19
+ aircraft_info = aircraft_data[aircraft_data["Aircraft Name"] == selected_aircraft].iloc[0]
20
+
21
+ st.subheader(aircraft_info["Aircraft Name"])
22
+
23
+ # Improved Image Display Handling
24
+ image_path = aircraft_info["Image URL"]
25
+
26
+ if os.path.exists(image_path):
27
  st.image(image_path, use_column_width=True, caption=aircraft_info["Aircraft Name"])
28
+ else:
29
  try:
30
  st.image(image_path, use_column_width=True, caption=aircraft_info["Aircraft Name"])
31
  except Exception as e:
32
  st.error(f"Error displaying image: {e}. Check the URL/path in the CSV.")
33
 
34
+
35
+ col1, col2 = st.columns(2)
36
+
37
+ with col1:
38
+ st.write(f"**Origin:** {aircraft_info['Origin']}")
39
+ st.write(f"**Manufacturer:** {aircraft_info['Manufacturer']}")
40
+ st.write(f"**First Flight:** {aircraft_info['First Flight']}")
41
+ st.write(f"**Introduction:** {aircraft_info['Introduction']}")
42
+ st.write(f"**Role:** {aircraft_info['Role']}")
43
+
44
+ with col2:
45
+ st.write(f"**Variants:** {aircraft_info['Variants']}")
46
+ st.write(f"**Crew:** {aircraft_info['Crew']}")
47
+ st.write(f"**Capacity:** {aircraft_info['Capacity']}")
48
+ st.write(f"**Length:** {aircraft_info['Length (m)']} m")
49
+ st.write(f"**Wingspan:** {aircraft_info['Wingspan (m)']} m")
50
+ st.write(f"**Height:** {aircraft_info['Height (m)']} m")
51
+ st.write(f"**Max Speed:** {aircraft_info['Max Speed (km/h)']} km/h")
52
+ st.write(f"**Range:** {aircraft_info['Range (km)']} km")
53
+ st.write(f"**Service Ceiling:** {aircraft_info['Service Ceiling (m)']} m")
54
+
55
+ with st.expander("Detailed Description"):
56
+ st.write(aircraft_info["Description"])
57
+
58
+ else:
59
+ st.write("Please select an aircraft to view its information.")