Update app.py
Browse files
app.py
CHANGED
@@ -20,12 +20,12 @@ def get_exchange_rate(from_currency: str, to_currency: str) -> float:
|
|
20 |
float: The exchange rate from the source currency to the target currency
|
21 |
"""
|
22 |
try:
|
23 |
-
api_url = f"https://open.er-api.com/v6/latest/{
|
24 |
response = requests.get(api_url)
|
25 |
|
26 |
if response.status_code == 200:
|
27 |
data = response.json()
|
28 |
-
return data['rates'][
|
29 |
else:
|
30 |
return f"Error: Unable to fetch exchange rate. Status code: {response.status_code}"
|
31 |
|
|
|
20 |
float: The exchange rate from the source currency to the target currency
|
21 |
"""
|
22 |
try:
|
23 |
+
api_url = f"https://open.er-api.com/v6/latest/{from_currency}"
|
24 |
response = requests.get(api_url)
|
25 |
|
26 |
if response.status_code == 200:
|
27 |
data = response.json()
|
28 |
+
return data['rates'][to_currency]
|
29 |
else:
|
30 |
return f"Error: Unable to fetch exchange rate. Status code: {response.status_code}"
|
31 |
|