|
import streamlit as st |
|
import requests |
|
import pandas as pd |
|
|
|
|
|
cryptos = [ |
|
"BTC", "ETH", "USDT", "BNB", "XRP", "ADA", "DOGE", "SOL", "DOT", |
|
"USDC", "LTC", "LINK", "MATIC", "AVAX", "XLM", "BCH", "SHIB", |
|
"UNI", "ATOM", "ALGO", "VET", "XMR", "FIL", "TRX", "XTZ", |
|
"AAVE", "HBAR", "ICP", "EGLD", "THETA" |
|
] |
|
|
|
|
|
def get_crypto_data(): |
|
url = "https://api.minerstat.com/v2/coins" |
|
params = { |
|
'list': ','.join(cryptos) |
|
} |
|
response = requests.get(url, params=params) |
|
return response.json() |
|
|
|
|
|
st.markdown( |
|
""" |
|
<style> |
|
.title { |
|
text-align: center; |
|
color: #4CAF50; |
|
font-size: 40px; |
|
font-weight: bold; |
|
} |
|
.subheader { |
|
text-align: center; |
|
color: #2196F3; |
|
font-size: 30px; |
|
} |
|
.button { |
|
background-color: #2196F3; |
|
color: white; |
|
font-size: 20px; |
|
padding: 10px 20px; |
|
border-radius: 5px; |
|
border: none; |
|
cursor: pointer; |
|
display: block; |
|
margin: 20px auto; |
|
text-align: center; |
|
text-decoration: none; |
|
width: 100%; /* Cambiado a 100% para ampliar el bot贸n */ |
|
max-width: 300px; /* Puedes ajustar el ancho m谩ximo seg煤n sea necesario */ |
|
} |
|
.button:hover { |
|
background-color: #1976D2; |
|
} |
|
.dataframe { |
|
margin: 0 auto; |
|
text-align: center; |
|
border-collapse: collapse; |
|
width: 90%; |
|
} |
|
.dataframe th, .dataframe td { |
|
padding: 10px; |
|
border: 1px solid #ddd; |
|
} |
|
</style> |
|
""", |
|
unsafe_allow_html=True |
|
) |
|
|
|
|
|
st.markdown('<h1 class="title">Estad铆sticas de Criptomonedas</h1>', unsafe_allow_html=True) |
|
st.markdown('<p style="text-align: center;">Esta aplicaci贸n muestra las estad铆sticas de las 5 criptomonedas m谩s populares.</p>', unsafe_allow_html=True) |
|
|
|
|
|
if st.button("Actualizar datos", key='update_button', help="Actualiza las estad铆sticas de criptomonedas"): |
|
data = get_crypto_data() |
|
df = pd.DataFrame(data) |
|
|
|
|
|
st.markdown('<h2 class="subheader">Estad铆sticas de las Criptomonedas</h2>', unsafe_allow_html=True) |
|
st.dataframe(df[['coin', 'name', 'price', 'volume', 'algorithm', 'difficulty', 'reward_block']], |
|
use_container_width=True) |
|
else: |
|
st.markdown('<p style="text-align: center;">Presiona el bot贸n para actualizar los datos.</p>', unsafe_allow_html=True) |