# app.py
import streamlit as st
st.set_page_config(page_title="Temperature Converter", page_icon=":thermometer:", layout="wide")
# Custom CSS for styling
st.markdown(
"""
""",
unsafe_allow_html=True,
)
st.title("Temperature Converter")
with st.container() as converter_container:
# Image (replace with your image URL or upload)
st.markdown("
", unsafe_allow_html=True)
col1, col2 = st.columns([1, 1])
with col1:
st.subheader("Input")
temperature = st.number_input("Temperature", value=0.0)
unit_from = st.selectbox("From", ["Celsius", "Fahrenheit", "Kelvin"])
with col2:
st.subheader("Output")
unit_to = st.selectbox("To", ["Celsius", "Fahrenheit", "Kelvin"])
if st.button("Convert"):
# ... (Conversion logic remains the same)
if unit_from == unit_to:
result = temperature
elif unit_from == "Celsius" and unit_to == "Fahrenheit":
result = (temperature * 9/5) + 32
elif unit_from == "Celsius" and unit_to == "Kelvin":
result = temperature + 273.15
elif unit_from == "Fahrenheit" and unit_to == "Celsius":
result = (temperature - 32) * 5/9
elif unit_from == "Fahrenheit" and unit_to == "Kelvin":
result = (temperature - 32) * 5/9 + 273.15
elif unit_from == "Kelvin" and unit_to == "Celsius":
result = temperature - 273.15
elif unit_from == "Kelvin" and unit_to == "Fahrenheit":
result = (temperature - 273.15) * 9/5 + 32
st.markdown(f"Result: {result:.2f} {unit_to}
", unsafe_allow_html=True)
# Quote
st.markdown("\"The only way to do great work is to love what you do.\" - Steve Jobs
", unsafe_allow_html=True)
st.markdown("---")
st.write("Made with Streamlit")