Spaces:
Build error
Build error
| import streamlit as st | |
| from PIL import Image | |
| import os | |
| # Set page configuration | |
| st.set_page_config( | |
| page_title="Fighter Aircraft Information", | |
| page_icon="✈️", | |
| layout="wide" | |
| ) | |
| # Aircraft Data Dictionary | |
| aircraft_data = { | |
| "F-16": { | |
| "Aircraft Name": "General Dynamics F-16 Fighting Falcon", | |
| "Image URL": "f16.jpeg", | |
| "Origin": "United States", | |
| "Manufacturer": "Lockheed Martin", | |
| "First Flight": 1974, | |
| "Introduction": 1979, | |
| "Role": "Multirole fighter", | |
| "Variants": "A, B, C, D, E, F", | |
| "Crew": 1, | |
| "Length (m)": 15.03, | |
| "Wingspan (m)": 9.96, | |
| "Height (m)": 5.09, | |
| "Max Speed (km/h)": 2414, | |
| "Range (km)": 3400, | |
| "Service Ceiling (m)": 15240, | |
| "Description": "The F-16 is a versatile multirole fighter known for its agility and combat effectiveness." | |
| }, | |
| "F-35": { | |
| "Aircraft Name": "Lockheed Martin F-35 Lightning II", | |
| "Image URL": "f35.jpg", | |
| "Origin": "United States", | |
| "Manufacturer": "Lockheed Martin", | |
| "First Flight": 2006, | |
| "Introduction": 2015, | |
| "Role": "Stealth multirole fighter", | |
| "Variants": "F-35A, F-35B, F-35C", | |
| "Crew": 1, | |
| "Length (m)": 15.67, | |
| "Wingspan (m)": 10.7, | |
| "Height (m)": 4.33, | |
| "Max Speed (km/h)": 1930, | |
| "Range (km)": 2220, | |
| "Service Ceiling (m)": 18288, | |
| "Description": "A fifth-generation stealth fighter designed for air superiority and electronic warfare." | |
| }, | |
| "F-22": { | |
| "Aircraft Name": "Lockheed Martin F-22 Raptor", | |
| "Image URL": "f22.jpg", | |
| "Origin": "United States", | |
| "Manufacturer": "Lockheed Martin", | |
| "First Flight": 1997, | |
| "Introduction": 2005, | |
| "Role": "Stealth air superiority fighter", | |
| "Variants": "F-22A", | |
| "Crew": 1, | |
| "Length (m)": 18.92, | |
| "Wingspan (m)": 13.56, | |
| "Height (m)": 5.08, | |
| "Max Speed (km/h)": 2414, | |
| "Range (km)": 2900, | |
| "Service Ceiling (m)": 20000, | |
| "Description": "The F-22 Raptor is a stealth fighter known for its maneuverability, speed, and air dominance capabilities." | |
| }, | |
| "F-15": { | |
| "Aircraft Name": "McDonnell Douglas F-15 Eagle", | |
| "Image URL": "f15.jpeg", | |
| "Origin": "United States", | |
| "Manufacturer": "McDonnell Douglas (now Boeing)", | |
| "First Flight": 1972, | |
| "Introduction": 1976, | |
| "Role": "Air superiority fighter", | |
| "Variants": "F-15A, F-15B, F-15C, F-15D, F-15E", | |
| "Crew": "1 (F-15C/E), 2 (F-15B/D)", | |
| "Length (m)": 19.43, | |
| "Wingspan (m)": 13.05, | |
| "Height (m)": 5.63, | |
| "Max Speed (km/h)": 3000, | |
| "Range (km)": 4445, | |
| "Service Ceiling (m)": 18000, | |
| "Description": "The F-15 Eagle is an all-weather tactical fighter designed for air superiority." | |
| }, | |
| "JF-17": { | |
| "Aircraft Name": "PAC JF-17 Thunder", | |
| "Image URL": "jf17.jpeg", | |
| "Origin": "Pakistan/China", | |
| "Manufacturer": "PAC / CAC", | |
| "First Flight": 2003, | |
| "Introduction": 2007, | |
| "Role": "Multirole fighter", | |
| "Variants": "Block 1, Block 2, Block 3", | |
| "Crew": 1, | |
| "Length (m)": 14.3, | |
| "Wingspan (m)": 9.92, | |
| "Height (m)": 4.77, | |
| "Max Speed (km/h)": 1900, | |
| "Range (km)": 2000, | |
| "Service Ceiling (m)": 16764, | |
| "Description": "The JF-17 Thunder is a lightweight, multirole fighter developed by Pakistan and China." | |
| }, | |
| "J-20": { | |
| "Aircraft Name": "Chengdu J-20 Mighty Dragon", | |
| "Image URL": "j20.jpeg", | |
| "Origin": "China", | |
| "Manufacturer": "Chengdu Aerospace Corporation", | |
| "First Flight": 2011, | |
| "Introduction": 2017, | |
| "Role": "Stealth air superiority fighter", | |
| "Variants": "J-20A, J-20B", | |
| "Crew": 1, | |
| "Length (m)": 20.4, | |
| "Wingspan (m)": 13.5, | |
| "Height (m)": 4.45, | |
| "Max Speed (km/h)": 2223, | |
| "Range (km)": 5500, | |
| "Service Ceiling (m)": 20000, | |
| "Description": "The J-20 Mighty Dragon is China's advanced stealth fighter designed for long-range operations." | |
| } | |
| } | |
| # Sidebar for Aircraft Selection | |
| st.sidebar.header("Select an Aircraft") | |
| selected_aircraft = st.sidebar.selectbox("Choose an aircraft:", list(aircraft_data.keys())) | |
| # Display Aircraft Information | |
| if selected_aircraft: | |
| aircraft_info = aircraft_data[selected_aircraft] | |
| st.header(aircraft_info["Aircraft Name"]) | |
| # Image Handling | |
| image_path = aircraft_info["Image URL"] | |
| default_image = "placeholder.jpg" | |
| try: | |
| img = Image.open(image_path) if os.path.exists(image_path) else Image.open(default_image) | |
| except Exception: | |
| img = Image.open(default_image) | |
| col1, col2 = st.columns([1, 2]) | |
| with col1: | |
| st.image(img, use_container_width=True, caption=aircraft_info["Aircraft Name"]) | |
| with col2: | |
| st.subheader("General Information") | |
| for key in ["Origin", "Manufacturer", "First Flight", "Introduction", "Role", "Variants", "Crew"]: | |
| st.write(f"**{key}:** {aircraft_info[key]}") | |
| st.subheader("🔹 Performance Specifications") | |
| cols = st.columns(3) | |
| specs = ["Length (m)", "Wingspan (m)", "Height (m)", "Max Speed (km/h)", "Range (km)", "Service Ceiling (m)"] | |
| for idx, col in enumerate(cols): | |
| with col: | |
| for key in specs[idx::3]: | |
| st.metric(label=key, value=aircraft_info[key]) | |
| with st.expander("ℹ️ More Information"): | |
| st.write(aircraft_info["Description"]) |