File size: 2,578 Bytes
c7af237 5401e78 712861f 9fc312d 712861f 13883ab 712861f 2dcf849 6359cc8 76260c7 2dcf849 712861f 2dcf849 712861f 362a3d6 6359cc8 712861f 9fc312d 712861f 13883ab 2dcf849 9fc312d 712861f 76260c7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
import streamlit as st
import requests
import pandas as pd
# Lista de criptomonedas
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"
]
# Funci贸n para obtener datos de la API
def get_crypto_data():
url = "https://api.minerstat.com/v2/coins"
params = {
'list': ','.join(cryptos)
}
response = requests.get(url, params=params)
return response.json()
# Estilos CSS para personalizaci贸n
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
)
# Inicializar la aplicaci贸n
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)
# Bot贸n para actualizar datos centrado
if st.button("Actualizar datos", key='update_button', help="Actualiza las estad铆sticas de criptomonedas"):
data = get_crypto_data()
df = pd.DataFrame(data)
# Ajustar ancho de la tabla
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) |