show a number of stories that fit the terminal window

This commit is contained in:
Felix Pankratz 2023-08-29 14:37:02 +02:00
parent 67136668f4
commit ed2e395e5f

4
hn.py
View File

@ -26,13 +26,13 @@ def main(stdscr):
stdscr.clear()
height, width = stdscr.getmaxyx()
num_stories = curses.LINES - 2 # headline and detail
num_stories = curses.LINES - 3 # headline, detail, footer
# Query Hacker News API for top stories and their titles/links
url = 'https://hacker-news.firebaseio.com/v0/topstories.json'
r = requests.get(url)
if not r.ok:
raise Exception('Error fetching data from Hacker News API')
ids = r.json()[:10]
ids = r.json()[:num_stories]
stories = []
for idx, i in enumerate(ids):
stdscr.clear()