Skip to content

Commit 14844a9

Browse files
fixing some errors
1 parent e9b0146 commit 14844a9

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

app.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,15 @@ async def stock_news(cache: RedisBackend = Depends(get_cache)):
9595
await cache.set(cache_key, json.dumps(news_stack), 300)
9696
return news_stack
9797

98-
@app.get("stocks/{name}")
98+
@app.get("/stocks/{name}")
9999
async def read_stock(name: str, cache: RedisBackend = Depends(get_cache)):
100-
cache_key = "stock"
100+
cache_key = "stock_{name}"
101101
cached_result = await cache.get(cache_key)
102102
if cached_result:
103103
return json.loads(cached_result)
104104
stock_info = get_stock(name)
105105
await cache.set(cache_key, json.dumps(stock_info), 10)
106+
return stock_info
106107

107108

108109
@app.get("health/") # Changed to GET since it's retrieving status

stockNews.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
if not NEWS_API_KEY:
1212
raise ValueError("Please provide a NEWS API key")
13-
13+
1414
session = requests.Session()
1515
session.headers.update({
1616
"User-Agent": "Chrome/122.0.0.0"

0 commit comments

Comments
 (0)