|
@@ -15,19 +15,21 @@ url = "https://vancouver-ca.smoove.pro/api-public/stations"
|
|
# old_data = json.load(f)
|
|
# old_data = json.load(f)
|
|
# data = old_data
|
|
# data = old_data
|
|
|
|
|
|
|
|
+# init globals
|
|
|
|
+data = None
|
|
|
|
+app = Flask(__name__)
|
|
|
|
+
|
|
def refresh_data():
|
|
def refresh_data():
|
|
|
|
+ global data
|
|
# try to get new data
|
|
# try to get new data
|
|
try:
|
|
try:
|
|
new = requests.get(url)
|
|
new = requests.get(url)
|
|
except requests.exceptions.RequestException:
|
|
except requests.exceptions.RequestException:
|
|
- print("failed to get data")
|
|
|
|
|
|
+ app.logger.error("failed to get data")
|
|
data = None
|
|
data = None
|
|
else:
|
|
else:
|
|
data = new.json()["result"]
|
|
data = new.json()["result"]
|
|
|
|
|
|
-# init libs
|
|
|
|
-app = Flask(__name__)
|
|
|
|
-
|
|
|
|
# main function to get data from api
|
|
# main function to get data from api
|
|
def get_bikes(station, metric):
|
|
def get_bikes(station, metric):
|
|
refresh_data()
|
|
refresh_data()
|