mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-07 03:07:46 +08:00
Enable ruff S113 rule (#11375)
* Enable ruff S113 rule * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -9,14 +9,14 @@ def get_apod_data(api_key: str) -> dict:
|
||||
Get your API Key from: https://api.nasa.gov/
|
||||
"""
|
||||
url = "https://api.nasa.gov/planetary/apod"
|
||||
return requests.get(url, params={"api_key": api_key}).json()
|
||||
return requests.get(url, params={"api_key": api_key}, timeout=10).json()
|
||||
|
||||
|
||||
def save_apod(api_key: str, path: str = ".") -> dict:
|
||||
apod_data = get_apod_data(api_key)
|
||||
img_url = apod_data["url"]
|
||||
img_name = img_url.split("/")[-1]
|
||||
response = requests.get(img_url, stream=True)
|
||||
response = requests.get(img_url, stream=True, timeout=10)
|
||||
|
||||
with open(f"{path}/{img_name}", "wb+") as img_file:
|
||||
shutil.copyfileobj(response.raw, img_file)
|
||||
@ -29,7 +29,7 @@ def get_archive_data(query: str) -> dict:
|
||||
Get the data of a particular query from NASA archives
|
||||
"""
|
||||
url = "https://images-api.nasa.gov/search"
|
||||
return requests.get(url, params={"q": query}).json()
|
||||
return requests.get(url, params={"q": query}, timeout=10).json()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Reference in New Issue
Block a user