Spaces:
Sleeping
Sleeping
app.py
Browse files7 unmodified lines89101112131423 unmodified lines383940414243447 unmodified linesurl = f"https://api.coingecko.com/api/v3/coins/{coin_id}/market_chart/range?vs_currency=usd&from={from_timestamp}&to={to_timestamp}"try:response = requests.get(url)response.raise_for_status() # Will raise an HTTPError for bad responsesdata = response.json()prices = data.get('prices', [])return prices23 unmodified linesprices = fetch_historical_data(coin_name, from_timestamp, to_timestamp)if isinstance(prices, str): # In case of errorreturn go.Figure()df = pd.DataFrame(prices, columns=['timestamp', 'price'])df['date'] = pd.to_datetime(df['timestamp'], unit='ms')7 unmodified lines89101112131423 unmodified lines383940414243447 unmodified linesurl = f"https://api.coingecko.com/api/v3/coins/{coin_id}/market_chart/range?vs_currency=usd&from={from_timestamp}&to={to_timestamp}"try:response = requests.get(url)response.raise_for_status()data = response.json()prices = data.get('prices', [])return prices23 unmodified linesprices = fetch_historical_data(coin_name, from_timestamp, to_timestamp)if isinstance(prices, str): # In case of errorreturn gr.Plot(label="Error").plot(go.Figure().update_layout(title=prices))df = pd.DataFrame(prices, columns=['timestamp', 'price'])df['date'] = pd.to_datetime(df['timestamp'], unit='ms')
app.py+2-2