Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,13 +2,13 @@ import streamlit as st
|
|
2 |
import requests
|
3 |
from datetime import datetime
|
4 |
|
5 |
-
# Fetch live exchange rates
|
6 |
def fetch_exchange_rates(base_currency="USD"):
|
7 |
-
url = f"https://
|
8 |
response = requests.get(url)
|
9 |
data = response.json()
|
10 |
if response.status_code == 200:
|
11 |
-
return data['
|
12 |
else:
|
13 |
st.error("Error fetching data. Please try again later.")
|
14 |
return {}
|
@@ -22,7 +22,7 @@ def convert_currency(amount, from_currency, to_currency, rates):
|
|
22 |
return converted_amount
|
23 |
|
24 |
# Set page config
|
25 |
-
st.set_page_config(page_title="Currency Converter", page_icon="
|
26 |
|
27 |
# Sidebar - Display current date
|
28 |
now = datetime.now()
|
@@ -34,12 +34,12 @@ st.sidebar.title("Currency Converter")
|
|
34 |
|
35 |
# Sidebar - Description
|
36 |
st.sidebar.markdown("""
|
37 |
-
This app allows you to convert between different currencies
|
38 |
Simply select the currencies, enter the amount, and click 'Convert'.
|
39 |
""")
|
40 |
|
41 |
-
# Sidebar - Currency list (
|
42 |
-
currency_list = ['USD', 'EUR', 'GBP', 'INR', 'AUD', 'CAD', 'JPY', 'CNY', 'CHF', 'MXN'
|
43 |
|
44 |
# Main title
|
45 |
st.title("Currency Conversion App")
|
@@ -48,13 +48,13 @@ st.title("Currency Conversion App")
|
|
48 |
st.markdown("""
|
49 |
<style>
|
50 |
.reportview-container {
|
51 |
-
background-color: #
|
52 |
}
|
53 |
.sidebar .sidebar-content {
|
54 |
-
background-color: #
|
55 |
}
|
56 |
.stButton>button {
|
57 |
-
background-color: #
|
58 |
color: white;
|
59 |
font-size: 16px;
|
60 |
border-radius: 5px;
|
@@ -62,7 +62,7 @@ st.markdown("""
|
|
62 |
border: none;
|
63 |
}
|
64 |
.stButton>button:hover {
|
65 |
-
background-color: #
|
66 |
}
|
67 |
</style>
|
68 |
""", unsafe_allow_html=True)
|
|
|
2 |
import requests
|
3 |
from datetime import datetime
|
4 |
|
5 |
+
# Fetch live exchange rates
|
6 |
def fetch_exchange_rates(base_currency="USD"):
|
7 |
+
url = f"https://api.exchangerate-api.com/v4/latest/{base_currency}"
|
8 |
response = requests.get(url)
|
9 |
data = response.json()
|
10 |
if response.status_code == 200:
|
11 |
+
return data['rates']
|
12 |
else:
|
13 |
st.error("Error fetching data. Please try again later.")
|
14 |
return {}
|
|
|
22 |
return converted_amount
|
23 |
|
24 |
# Set page config
|
25 |
+
st.set_page_config(page_title="Currency Converter", page_icon="💰", layout="wide")
|
26 |
|
27 |
# Sidebar - Display current date
|
28 |
now = datetime.now()
|
|
|
34 |
|
35 |
# Sidebar - Description
|
36 |
st.sidebar.markdown("""
|
37 |
+
This app allows you to convert between different currencies.
|
38 |
Simply select the currencies, enter the amount, and click 'Convert'.
|
39 |
""")
|
40 |
|
41 |
+
# Sidebar - Currency list (use the most popular currencies)
|
42 |
+
currency_list = ['USD', 'EUR', 'GBP', 'INR', 'AUD', 'CAD', 'JPY', 'CNY', 'CHF', 'MXN']
|
43 |
|
44 |
# Main title
|
45 |
st.title("Currency Conversion App")
|
|
|
48 |
st.markdown("""
|
49 |
<style>
|
50 |
.reportview-container {
|
51 |
+
background-color: #f0f8ff; /* Light Blue background */
|
52 |
}
|
53 |
.sidebar .sidebar-content {
|
54 |
+
background-color: #f0f8ff; /* Light Blue for sidebar */
|
55 |
}
|
56 |
.stButton>button {
|
57 |
+
background-color: #008CBA;
|
58 |
color: white;
|
59 |
font-size: 16px;
|
60 |
border-radius: 5px;
|
|
|
62 |
border: none;
|
63 |
}
|
64 |
.stButton>button:hover {
|
65 |
+
background-color: #005f6a;
|
66 |
}
|
67 |
</style>
|
68 |
""", unsafe_allow_html=True)
|