Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,6 @@ import requests
|
|
| 2 |
import matplotlib.pyplot as plt
|
| 3 |
import matplotlib.dates as mdates
|
| 4 |
import os
|
| 5 |
-
import time
|
| 6 |
from datetime import datetime, timedelta
|
| 7 |
import numpy as np
|
| 8 |
import streamlit as st
|
|
@@ -78,15 +77,18 @@ def send_to_discord(prices, image_path):
|
|
| 78 |
with open(image_path, 'rb') as f:
|
| 79 |
requests.post(DISCORD_WEBHOOK_URL, json=embed, files={"file": (image_path, f)})
|
| 80 |
|
| 81 |
-
|
| 82 |
-
|
|
|
|
| 83 |
prices = get_crypto_prices()
|
| 84 |
-
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
send_to_discord(prices, 'crypto_prices_rectangle.png')
|
| 90 |
|
| 91 |
-
|
| 92 |
-
|
|
|
|
| 2 |
import matplotlib.pyplot as plt
|
| 3 |
import matplotlib.dates as mdates
|
| 4 |
import os
|
|
|
|
| 5 |
from datetime import datetime, timedelta
|
| 6 |
import numpy as np
|
| 7 |
import streamlit as st
|
|
|
|
| 77 |
with open(image_path, 'rb') as f:
|
| 78 |
requests.post(DISCORD_WEBHOOK_URL, json=embed, files={"file": (image_path, f)})
|
| 79 |
|
| 80 |
+
# Exécuter au chargement de la page
|
| 81 |
+
@st.cache_resource(show_spinner=False)
|
| 82 |
+
def run_on_load():
|
| 83 |
prices = get_crypto_prices()
|
| 84 |
+
st.write(f"Prix récupérés: {prices}")
|
| 85 |
+
|
| 86 |
+
prices_history = {coin: prices.get(coin, []) for coin in ['bitcoin', 'ethereum', 'tether', 'ripple']}
|
| 87 |
+
create_graph(prices_history)
|
| 88 |
+
send_to_discord(prices, 'crypto_prices_rectangle.png')
|
| 89 |
|
| 90 |
+
st.image('crypto_prices_rectangle.png')
|
| 91 |
+
st.success("Graphique créé et envoyé à Discord!")
|
|
|
|
| 92 |
|
| 93 |
+
st.title("Suivi des Prix des Cryptomonnaies")
|
| 94 |
+
run_on_load()
|