def apod(): url = current_app.config['APOD_URL'] params = {'api_key': get_jwt(), **get_json(PayloadSchema())} apod_request = Request(url, params=params) response = apod_request.get().json() if 'thumbnail_url' in response: image_url = response['thumbnail_url'] else: image_url = (response['hdurl'] if bool(params['hd']) else response['url']) content = requests.get(image_url).content path = get_media_path() file_name = get_file_name(params['date']) save_image(content, path, file_name) return jsonify({ 'status': 'Success! Image saved.', 'path': os.path.join(path, file_name), })
def cme(): url = current_app.config['CME_URL'] params = {'api_key': get_jwt(), **get_params(CMEPayloadSchema())} cme_request = Request(url, params=params) response = cme_request.get().json() cme_info = form_cme_data(response) return jsonify(cme_info)