Mavhas commited on
Commit
b6b9e6b
·
verified ·
1 Parent(s): 22e47c0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +154 -0
app.py ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import os
4
+ from PIL import Image
5
+ import io
6
+
7
+ st.set_page_config(page_title="Fighter Aircraft Information", page_icon=":airplane:", layout="wide")
8
+
9
+ # Aircraft Data (Dictionary)
10
+ aircraft_data = {
11
+ "F-16": {
12
+ "Aircraft Name": "General Dynamics F-16 Fighting Falcon",
13
+ "Image URL": "f16.jpeg", # Replace with actual filename
14
+ "Origin": "United States",
15
+ "Manufacturer": "General Dynamics (now Lockheed Martin)",
16
+ "First Flight": 1974,
17
+ "Introduction": 1979,
18
+ "Role": "Multirole fighter",
19
+ "Variants": "Numerous variants (A, B, C, D, E, F, etc.)",
20
+ "Crew": 1,
21
+ "Capacity": "N/A",
22
+ "Length (m)": 15.03,
23
+ "Wingspan (m)": 9.96,
24
+ "Height (m)": 5.09,
25
+ "Max Speed (km/h)": 2414,
26
+ "Range (km)": 3400,
27
+ "Service Ceiling (m)": 15240,
28
+ "Description": "The F-16 is a highly versatile, multirole fighter, known for its speed, agility, and adaptability. It has served in numerous conflicts and remains a mainstay of many air forces."
29
+ },
30
+ "F-35": {
31
+ "Aircraft Name": "Lockheed Martin F-35 Lightning II",
32
+ "Image URL": "f35.jpg", # Replace with actual filename
33
+ "Origin": "United States",
34
+ "Manufacturer": "Lockheed Martin",
35
+ "First Flight": 2006,
36
+ "Introduction": 2015,
37
+ "Role": "Multirole fighter (stealth)",
38
+ "Variants": "F-35A, F-35B, F-35C",
39
+ "Crew": 1,
40
+ "Capacity": "N/A",
41
+ "Length (m)": 15.67,
42
+ "Wingspan (m)": 10.7,
43
+ "Height (m)": 4.33,
44
+ "Max Speed (km/h)": 1930,
45
+ "Range (km)": 2220,
46
+ "Service Ceiling (m)": 18288,
47
+ "Description": "The F-35 is a fifth-generation, stealth multirole fighter. It is designed for air superiority, strike missions, and electronic warfare, and is notable for its advanced technology and sensor fusion."
48
+ },
49
+ "F-22": {
50
+ "Aircraft Name": "Lockheed Martin F-22 Raptor",
51
+ "Image URL": "f22.jpg", # Replace with actual filename
52
+ "Origin": "United States",
53
+ "Manufacturer": "Lockheed Martin",
54
+ "First Flight": 1997,
55
+ "Introduction": 2005,
56
+ "Role": "Air superiority fighter (stealth)",
57
+ "Variants": "F-22A",
58
+ "Crew": 1,
59
+ "Capacity": "N/A",
60
+ "Length (m)": 18.92,
61
+ "Wingspan (m)": 13.56,
62
+ "Height (m)": 5.08,
63
+ "Max Speed (km/h)": 2414,
64
+ "Range (km)": 2900,
65
+ "Service Ceiling (m)": 20000,
66
+ "Description": "The F-22 Raptor is a fifth-generation, stealth air superiority fighter. It is considered one of the most advanced and capable fighter aircraft in the world, known for its exceptional stealth, speed, and maneuverability."
67
+ },
68
+ "F-15": {
69
+ "Aircraft Name": "McDonnell Douglas F-15 Eagle",
70
+ "Image URL": "f15.jpeg", # Replace with actual filename
71
+ "Origin": "United States",
72
+ "Manufacturer": "McDonnell Douglas (now Boeing)",
73
+ "First Flight": 1972,
74
+ "Introduction": 1976,
75
+ "Role": "Air superiority fighter",
76
+ "Variants": "F-15A, F-15B, F-15C, F-15D, F-15E",
77
+ "Crew": "1 (F-15C/E), 2 (F-15B/D)",
78
+ "Capacity": "N/A",
79
+ "Length (m)": 19.43,
80
+ "Wingspan (m)": 13.05,
81
+ "Height (m)": 5.63,
82
+ "Max Speed (km/h)": 3000,
83
+ "Range (km)": 4445,
84
+ "Service Ceiling (m)": 18000,
85
+ "Description": "The F-15 Eagle is a twin-engine, all-weather tactical fighter designed for air superiority. It has a long combat record and is highly regarded for its speed, range, and weapons payload."
86
+ },
87
+ "JF-17": {
88
+ "Aircraft Name": "PAC JF-17 Thunder",
89
+ "Image URL": "jf17.jpg", # Replace with actual filename
90
+ "Origin": "Pakistan/China",
91
+ "Manufacturer": "Pakistan Aeronautical Complex (PAC) / Chengdu Aircraft Corporation (CAC)",
92
+ "First Flight": 2003,
93
+ "Introduction": 2007,
94
+ "Role": "Multirole fighter",
95
+ "Variants": "JF-17 Block 1, JF-17 Block 2, JF-17 Block 3",
96
+ "Crew": 1,
97
+ "Capacity": "N/A",
98
+ "Length (m)": 14.3,
99
+ "Wingspan (m)": 9.92,
100
+ "Height (m)": 4.77,
101
+ "Max Speed (km/h)": 1900,
102
+ "Range (km)": 2000,
103
+ "Service Ceiling (m)": 16764,
104
+ "Description": "The JF-17 Thunder is a lightweight, all-weather, multirole fighter aircraft developed jointly by Pakistan and China. It is designed for various roles, including air interception, ground attack, and close air support."
105
+ }
106
+ }
107
+
108
+ st.title("Fighter Aircraft Information")
109
+
110
+ # Sidebar for selection
111
+ st.sidebar.title("Select Aircraft")
112
+ aircraft_names = list(aircraft_data.keys())
113
+ selected_aircraft = st.sidebar.selectbox("Choose an aircraft:", aircraft_names)
114
+
115
+ if selected_aircraft:
116
+ aircraft_info = aircraft_data[selected_aircraft]
117
+
118
+ st.header(aircraft_info["Aircraft Name"]) # More prominent header
119
+
120
+ # Image display with improved error handling and centering
121
+ image_path = aircraft_info["Image URL"]
122
+ if image_path:
123
+ if os.path.exists(image_path):
124
+ try:
125
+ img = Image.open(image_path)
126
+ new_img = img.resize((300, 200)) # Resize as needed
127
+ col1, col2, col3 = st.columns([1, 2, 1])
128
+ with col2:
129
+ st.image(new_img, use_column_width=True, caption=aircraft_info["Aircraft Name"])
130
+
131
+ except Exception as e:
132
+ st.error(f"Error displaying image: {e}")
133
+
134
+ else:
135
+ st.error(f"Image not found: {image_path}")
136
+ else:
137
+ st.warning("No image URL provided.")
138
+
139
+ col1, col2 = st.columns(2) # Two-column layout for information
140
+
141
+ with col1:
142
+ st.subheader("General Information") # Subheader for organization
143
+ for key, value in aircraft_info.items():
144
+ if key not in ["Aircraft Name", "Image URL", "Description"]: # Exclude these
145
+ st.write(f"**{key}:** {value}")
146
+
147
+ with col2:
148
+ st.subheader("Performance Specs") # Subheader for organization
149
+ for key, value in aircraft_info.items():
150
+ if key in ["Length (m)", "Wingspan (m)", "Height (m)", "Max Speed (km/h)", "Range (km)", "Service Ceiling (m)"]:
151
+ st.write(f"**{key}:** {value}")
152
+
153
+ with st.expander("Detailed Description"): # Expandable description
154
+ st.write(aircraft_info["Description"])