I am wondering how I could display top headlines on a webpage using the news api and flask.
from newsapi import NewsApiClient
from flask import Flask
app = Flask(__name__)
newsapi = NewsApiClient(api_key='c732639b55f241f2acdf147fb646bf51')
data = newsapi.get_top_headlines(sources='bbc-news', language='en')
@app.route("/")
def home():
return data
if __name__ == "__main__":
app.run(debug=True)
This returns the dictionary containing all the keys such as title, author, date etc etc.. How can I display this dictionary as a list of headlines onlines?
Thanks so much
Aucun commentaire:
Enregistrer un commentaire