diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1d17dae --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.venv diff --git a/random_quotes.py b/random_quotes.py index 147bafb..6f980c6 100644 --- a/random_quotes.py +++ b/random_quotes.py @@ -3,8 +3,10 @@ from dotenv import load_dotenv from os import getenv from random import randint from requests import get, post +from sys import argv def load_env(): + load_dotenv() api_key = getenv('QUOTES_ACCESS_TOKEN') quotes_library = getenv('QUOTES_LIBRARY') if quotes_library.startswith('https',0): @@ -40,6 +42,10 @@ def make_post(headers, payload): print('An error occurred: ', e) if __name__ == '__main__': + if len(argv) > 0: + choice = int(argv[1]) + else: + choice = int(0) api_key, quote_file = load_env() - headers, payload = build_post(api_key, quote_file) + headers, payload = build_post(api_key, quote_file, choice) make_post(headers, payload) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..6fdb977 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +certifi==2024.2.2 +charset-normalizer==3.3.2 +idna==3.6 +python-dotenv==1.0.1 +requests==2.31.0 +urllib3==2.2.1