Skip to content

Commit

Permalink
add urlparse
Browse files Browse the repository at this point in the history
  • Loading branch information
Familenko committed Dec 7, 2023
1 parent c4ee8f7 commit 0cb27dc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
8 changes: 5 additions & 3 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import requests
from dotenv import load_dotenv
from urllib.parse import urlparse

load_dotenv()

Expand All @@ -16,9 +17,10 @@ def get_weather(
api_key: str = API_KEY
) -> None:
"""Get weather from API and print it."""
main_api = "https://weatherapi.com/"
msg_api = f"You need to visit {main_api} and get your API key."
msg_doc = f"You may visit {main_api}/docs/ for more information."
parsed_url = urlparse(url)
domain = parsed_url.netloc
msg_api = f"You need to visit {domain} and get your API key."
msg_doc = f"You may visit {domain}/docs/ for more information."

params = {"key": api_key, "q": filtering}

Expand Down
13 changes: 10 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
attrs==23.1.0
certifi==2023.11.17
charset-normalizer==3.3.2
flake8==5.0.4
flake8-annotations==2.9.1
flake8-quotes==3.3.1
flake8-variables-names==0.0.5
idna==3.6
mccabe==0.7.0
pep8-naming==0.13.2

requests~=2.31.0
python-dotenv~=1.0.0
pycodestyle==2.9.1
pyflakes==2.5.0
python-dotenv==1.0.0
requests==2.31.0
urllib3==2.1.0

0 comments on commit 0cb27dc

Please sign in to comment.