Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,18 +16,28 @@ 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 |
-
try:
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
"vs_currencies": "inr"}
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
except:
|
| 30 |
-
return f"Error fetching prices for {cryptos}."
|
| 31 |
|
| 32 |
|
| 33 |
|
|
|
|
| 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 |
+
url = "https://api.coingecko.com/api/v3/simple/price"
|
| 33 |
+
cryptos = ','.join(c for c in cryptocurrencies)
|
| 34 |
+
parms = {"ids": cryptos,
|
| 35 |
"vs_currencies": "inr"}
|
| 36 |
+
response = requests.get(url, params=params)
|
| 37 |
+
data = response.json()
|
| 38 |
+
for keys, values in data.items():
|
| 39 |
+
results.append(f"the price of {keys} is {values['inr']}.")
|
| 40 |
+
return ''.join(result for result in results)
|
|
|
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
|