Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
OPelham committed Jan 8, 2022
1 parent cb88149 commit c2a739a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.idea/

# temporary solution for hiding API Keys
secrets.py

# End of https://www.toptal.com/developers/gitignore/api/flask

8 changes: 5 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from flask import Flask, render_template, redirect
import requests

import secrets

app = Flask(__name__)

@app.route('/')
Expand Down Expand Up @@ -37,7 +39,7 @@ def sport():


def call_news_api(end_point):
custom_headers = {"x-api-key": "59bceb20876d4a8f97bb58762a79b86a"}
custom_headers = {"x-api-key": secrets.NEWS_API_KEY}
news_request = requests.get(end_point, headers=custom_headers)
news_response_json = dict(news_request.json())
articles = news_response_json.get("articles")
Expand All @@ -52,7 +54,7 @@ def weather():

def enquire_current_weather():
location_default = "Rangiora"
_API_key = "70f646114a0cf8d45f17792318c2950a"
_API_key = secrets.WEATHER_API_KEY
_end_point_base = "https://api.openweathermap.org/data/2.5/weather?q={}, NZ&appid={}&units=metric"
end_point = _end_point_base.format(location_default, _API_key)
weather_response = requests.get(end_point).json()
Expand Down Expand Up @@ -92,7 +94,7 @@ def enquire_current_weather():

def enquire_7_day_forcast():
location_default = "2192362" # how get this from user? and how marry to id for call
_API_key = "70f646114a0cf8d45f17792318c2950a"
_API_key = secrets.WEATHER_API_KEY
_end_point_base = "https://api.openweathermap.org/data/2.5/weather?q={}, NZ&appid={}&units=metric"
end_point = _end_point_base.format(location_default, _API_key)
weather_response = requests.get(end_point).json()
Expand Down

0 comments on commit c2a739a

Please sign in to comment.