0o7Hunk commited on
Commit
80b2109
·
verified ·
1 Parent(s): eaec7a3

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+
4
+ st.title("💱 Simple Currency Converter")
5
+
6
+ # Input amount
7
+ amount = st.number_input("Enter amount", value=1.0)
8
+
9
+ # From currency
10
+ from_currency = st.selectbox("From currency", ["USD", "EUR", "GBP", "JPY", "INR"])
11
+
12
+ # To currency
13
+ to_currency = st.selectbox("To currency", ["USD", "EUR", "GBP", "JPY", "INR"])
14
+
15
+ # Fetch exchange rate
16
+ if st.button("Convert"):
17
+ url = f"https://api.exchangerate.host/convert?from={from_currency}&to={to_currency}&amount={amount}"
18
+ response = requests.get(url)
19
+ data = response.json()
20
+ if data.get("success"):
21
+ converted_amount = data["result"]
22
+ st.success(f"{amount} {from_currency} = {converted_amount:.2f} {to_currency}")
23
+ else:
24
+ st.error("Failed to retrieve data. Try again later.")