LuxOAI commited on
Commit
06fc880
1 Parent(s): 1622dfc
Files changed (1) hide show
  1. APP +38 -0
APP ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import pandas as pd
3
+ import gradio as gr
4
+
5
+ # Assuming we have an API endpoint that provides the required data
6
+ API_ENDPOINT = "https://api.example.com/crypto/top-volume/12h"
7
+
8
+ def fetch_top_cryptos():
9
+ # Placeholder for API call and data processing
10
+ # In a real scenario, replace this with a call to the actual API
11
+ response = requests.get(API_ENDPOINT)
12
+ if response.status_code == 200:
13
+ data = response.json()
14
+ # Assuming the API returns data in a format that can be directly converted to a DataFrame
15
+ df = pd.DataFrame(data)
16
+ # Selecting and formatting the relevant columns
17
+ df = df[['name', 'volume_invested']]
18
+ return df
19
+ else:
20
+ return "Error fetching data"
21
+
22
+ # Gradio interface
23
+ iface = gr.Interface(
24
+ fn=fetch_top_cryptos,
25
+ inputs=None,
26
+ outputs="dataframe",
27
+ title="Top Cryptocurrencies by Volume",
28
+ description="Shows the top cryptocurrencies by volume invested in the past 12 hours."
29
+ )
30
+
31
+ # The API key for deploying on Hugging Face Spaces
32
+ api_key = "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"
33
+
34
+ # Launch the app locally for testing
35
+ if __name__ == "__main__":
36
+ iface.launch()
37
+
38
+ # To deploy on Hugging Face Spaces, use the `launch` method with `share=True` and the `api_key` parameter