show a number of stories that fit the terminal window
This commit is contained in:
parent
67136668f4
commit
ed2e395e5f
4
hn.py
4
hn.py
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user