diff --git a/app/request_datasets.py b/app/request_datasets.py index 38e85d8..c5cbb3b 100644 --- a/app/request_datasets.py +++ b/app/request_datasets.py @@ -1,5 +1,5 @@ from constants import datasets, url -from requests import get +from requests import get, codes from json import dump @@ -10,13 +10,22 @@ def save_json(data): def request_dataset(url): request = get(url) + validate_request(request) data = request.json() save_json(data) - -def main(): - url.format("deconfinement-pistes-cyclables-temporaires") + +def validate_request(req): + try: + req.status_code == codes.ok() + except Exception: + print("Error") + + +def format_url(): + for i in datasets: + link = url.format(datasets[i]) + request_dataset(link) + -if __name__ == "__main__": - main()