import requests import pandas as pd import gradio as gr # Assuming we have an API endpoint that provides the required data API_ENDPOINT = "https://api.example.com/crypto/top-volume/12h" def fetch_top_cryptos(): # Placeholder for API call and data processing # In a real scenario, replace this with a call to the actual API response = requests.get(API_ENDPOINT) if response.status_code == 200: data = response.json() # Assuming the API returns data in a format that can be directly converted to a DataFrame df = pd.DataFrame(data) # Selecting and formatting the relevant columns df = df[['name', 'volume_invested']] return df else: return "Error fetching data" # Gradio interface iface = gr.Interface( fn=fetch_top_cryptos, inputs=None, outputs="dataframe", title="Top Cryptocurrencies by Volume", description="Shows the top cryptocurrencies by volume invested in the past 12 hours." ) # The API key for deploying on Hugging Face Spaces api_key = "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" # Launch the app locally for testing if __name__ == "__main__": iface.launch() # To deploy on Hugging Face Spaces, use the `launch` method with `share=True` and the `api_key` parameter