Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,27 +16,18 @@ def live_crypto_price(cryptocurrencies:list)-> str: #it's import to specify the
|
|
| 16 |
cryptocurrencies: list containing the cryptocurrencies of which prices are required (e.g., ['bitcoin', 'cardano'])
|
| 17 |
"""
|
| 18 |
results = []
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
# vs_currencies: "inr"}
|
| 24 |
-
# response = requests.get(url, params=params)
|
| 25 |
-
# data = response.json()
|
| 26 |
-
# for keys, values in data.items():
|
| 27 |
-
# results.append(f"the price of {keys} is {values['inr']}.")
|
| 28 |
-
# return ''.join(result for result in results)
|
| 29 |
-
# except:
|
| 30 |
-
# return f"Error fetching prices for {cryptos}."
|
| 31 |
-
url = "https://api.coingecko.com/api/v3/simple/price"
|
| 32 |
-
cryptos = ','.join(c for c in cryptocurrencies)
|
| 33 |
-
parms = {ids: cryptos,
|
| 34 |
vs_currencies: "inr"}
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
| 40 |
|
| 41 |
|
| 42 |
|
|
|
|
| 16 |
cryptocurrencies: list containing the cryptocurrencies of which prices are required (e.g., ['bitcoin', 'cardano'])
|
| 17 |
"""
|
| 18 |
results = []
|
| 19 |
+
try:
|
| 20 |
+
url = "https://api.coingecko.com/api/v3/simple/price"
|
| 21 |
+
cryptos = ','.join(c for c in cryptocurrencies)
|
| 22 |
+
parms = {ids: cryptos,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
vs_currencies: "inr"}
|
| 24 |
+
response = requests.get(url, params=params)
|
| 25 |
+
data = response.json()
|
| 26 |
+
for keys, values in data.items():
|
| 27 |
+
results.append(f"the price of {keys} is {values['inr']}.")
|
| 28 |
+
return ''.join(result for result in results)
|
| 29 |
+
except:
|
| 30 |
+
return f"Error fetching prices for {cryptos}."
|
| 31 |
|
| 32 |
|
| 33 |
|