rioanggara commited on
Commit
96f9491
·
1 Parent(s): f2ba8f4
Files changed (1) hide show
  1. app.py +22 -16
app.py CHANGED
@@ -1,24 +1,30 @@
1
  import gradio as gr
2
- import time
 
3
 
4
- def start_pomodoro(duration):
5
- # This function will simulate a Pomodoro timer.
6
- # Real asynchronous waiting or background tasks aren't feasible with Gradio in its current state,
7
- # so we'll return a message instead of a real timer.
8
-
9
- if duration == 25:
10
- return "Pomodoro started! Work for 25 minutes."
11
- elif duration == 5:
12
- return "Short break started! Relax for 5 minutes."
 
 
 
 
13
  else:
14
- return "Long break started! Relax for 15 minutes."
15
 
 
16
  iface = gr.Interface(
17
- fn=start_pomodoro,
18
- inputs=gr.Dropdown(choices=[25, 5, 15], label="Select Duration (minutes)"),
19
- outputs="text",
20
- title="Simple Pomodoro Timer",
21
- description="Select duration and start a Pomodoro timer. Currently, the timer is simulated; it doesn't count down in real-time."
22
  )
23
 
24
  if __name__ == "__main__":
 
1
  import gradio as gr
2
+ import requests
3
+ import pandas as pd
4
 
5
+ # Alpha Vantage API key
6
+ API_KEY = "PJRAUD6KHJ2O097X"
7
+
8
+ # Function to fetch stock data
9
+ def get_stock_data(symbol):
10
+ url = f"https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol={symbol}&apikey={API_KEY}"
11
+ response = requests.get(url)
12
+ data = response.json()
13
+
14
+ if "Time Series (Daily)" in data:
15
+ df = pd.DataFrame(data["Time Series (Daily)"]).T
16
+ df.columns = ["Open", "High", "Low", "Close", "Volume"]
17
+ return df.head().to_html() # Display the latest 5 days of data
18
  else:
19
+ return "Data not found or invalid stock symbol."
20
 
21
+ # Gradio app interface
22
  iface = gr.Interface(
23
+ fn=get_stock_data,
24
+ inputs=gr.Textbox(label="Stock Symbol", placeholder="Enter a stock symbol (like AAPL, MSFT)"),
25
+ outputs="html",
26
+ title="Stock Market Data App",
27
+ description="Enter a stock symbol to fetch its daily time series data."
28
  )
29
 
30
  if __name__ == "__main__":