Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change secrets to dotenv based instead of config files #140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ Thumbs.db
.python-version

# for API keys
**/config.py
**/.env
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ mock==4.0.3
plotly==4.14.3
dash_bootstrap_components==0.11.3
scikit_learn==0.24.1
python-dotenv
7 changes: 5 additions & 2 deletions routemodel/data_retrieval/common.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import requests
import sys
import os.path
from dotenv import load_dotenv

sys.path.append(os.path.dirname(__file__))

from config import BASE_URL, API_KEY
load_dotenv()
BING_API_KEY = os.environ.get("BING_API_KEY")
BASE_URL = 'https://dev.virtualearth.net/REST/v1/'

# common getter for all files
def get_API_data(query: str):
Expand All @@ -13,7 +16,7 @@ def get_API_data(query: str):
#return: a JSON response from API
"""
url = BASE_URL + query
url += '&key={}'.format(API_KEY)
url += '&key={}'.format(BING_API_KEY)
# get and return response
try:
response = requests.get(url)
Expand Down
7 changes: 0 additions & 7 deletions routemodel/data_retrieval/config_example.py

This file was deleted.

5 changes: 4 additions & 1 deletion routemodel/data_retrieval/get_weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
import requests
import csv
import json
from dotenv import load_dotenv

load_dotenv()
WEATHER_API_KEY = os.environ.get("WEATHER_API_KEY")

from config import WEATHER_API_KEY
ONE_CALL_BASE = 'https://api.openweathermap.org/data/2.5/onecall?'
PATH = os.path.join(os.path.dirname(__file__), '..', 'routes\ASC2021\ASC2021_draft.csv')

Expand Down