Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,10 +7,17 @@ def get_stock_info(symbol):
|
|
7 |
price = stock_info.get_live_price(symbol)
|
8 |
# Fetch company information
|
9 |
company_info = stock_info.get_quote_table(symbol)
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
except Exception as e:
|
12 |
return f"Error retrieving data: {e}"
|
13 |
|
|
|
14 |
iface = gr.Interface(fn=get_stock_info,
|
15 |
inputs=gr.Textbox(label="Enter Stock Symbol (e.g., AAPL)"),
|
16 |
outputs="text",
|
|
|
7 |
price = stock_info.get_live_price(symbol)
|
8 |
# Fetch company information
|
9 |
company_info = stock_info.get_quote_table(symbol)
|
10 |
+
|
11 |
+
# Handling 'None' values gracefully if they exist
|
12 |
+
company_name = company_info.get('Name', 'N/A')
|
13 |
+
sector = company_info.get('Sector', 'N/A')
|
14 |
+
market_cap = company_info.get('Market Cap', 'N/A')
|
15 |
+
|
16 |
+
return f"Company: {company_name}\nSector: {sector}\nMarket Cap: {market_cap}\nStock Price: ${price:.2f}"
|
17 |
except Exception as e:
|
18 |
return f"Error retrieving data: {e}"
|
19 |
|
20 |
+
# Gradio Interface
|
21 |
iface = gr.Interface(fn=get_stock_info,
|
22 |
inputs=gr.Textbox(label="Enter Stock Symbol (e.g., AAPL)"),
|
23 |
outputs="text",
|