-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
70 lines (47 loc) · 2.08 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from flask import Flask, render_template, redirect
from helpers.news_api import call_news_api
from helpers.weather_api import enquire_current_weather
app = Flask(__name__)
@app.route('/')
def index():
return redirect('/news/')
@app.route('/news/')
def news():
end_point = "https://newsapi.org/v2/everything?domains=rnz.co.nz,bbc.com,dw.com,aljazeera.com&pagesize=100&language=en"
articles = call_news_api(end_point)
return render_template('news.html', articles=articles, title='headlines')
@app.route('/newzealand/')
def newzealand():
end_point = "https://newsapi.org/v2/everything?domains=rnz.co.nz,nzherald.co.nz,newshub.co.nz,odt.co.nz,stuff.co.nz&pagesize=100&language=en"
articles = call_news_api(end_point)
return render_template('news.html', articles=articles, title='new zealand')
@app.route('/technology/')
def technology():
end_point = "https://newsapi.org/v2/top-headlines?category=technology&pagesize=100&language=en"
tech_articles = call_news_api(end_point)
return render_template('news.html', articles=tech_articles, title='technology')
@app.route('/business/')
def business():
end_point = "https://newsapi.org/v2/top-headlines?category=business&pagesize=100&language=en"
business_articles = call_news_api(end_point)
return render_template('news.html', articles=business_articles, title='business')
@app.route('/sport/')
def sport():
end_point = "https://newsapi.org/v2/top-headlines?category=sport&pagesize=100&language=en"
sport_articles = call_news_api(end_point)
return render_template('news.html', articles=sport_articles, title='sport')
@app.route('/weather/')
def weather():
current_weather_dictionary = enquire_current_weather()
return render_template('weather.html', current_weather=current_weather_dictionary, title='weather')
@app.route('/football/')
def football():
return render_template('football.html')
@app.route('/covid/')
def covid():
return render_template('covid.html')
@app.route('/quiz/')
def quiz():
return render_template('quiz.html')
if __name__ == "__main__":
app.run(debug=True)