Spaces:
Runtime error
Runtime error
finally fixed
Browse files
app.py
CHANGED
|
@@ -39,14 +39,12 @@ def get_stock_price(symbol: str) -> float:
|
|
| 39 |
Args:
|
| 40 |
symbol: A string representing a valid stock (e.g., 'aapl').
|
| 41 |
"""
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
# else:
|
| 49 |
-
# return ("Error:", response.status_code, response.text)
|
| 50 |
|
| 51 |
|
| 52 |
final_answer = FinalAnswerTool()
|
|
|
|
| 39 |
Args:
|
| 40 |
symbol: A string representing a valid stock (e.g., 'aapl').
|
| 41 |
"""
|
| 42 |
+
api_url = 'https://api.api-ninjas.com/v1/stockprice?ticker={}'.format(symbol)
|
| 43 |
+
response = requests.get(api_url, headers={'X-Api-Key': 'tLxWjj6xXdYXkyajGKBdKQ==ncmATTD1rqr2s2Hb'})
|
| 44 |
+
if response.status_code == requests.codes.ok:
|
| 45 |
+
return (response.json()['price'])
|
| 46 |
+
else:
|
| 47 |
+
return ("Error:", response.status_code, response.text)
|
|
|
|
|
|
|
| 48 |
|
| 49 |
|
| 50 |
final_answer = FinalAnswerTool()
|