fully modularise quotesbot code for public consumption
This commit is contained in:
parent
7a9a41ccc9
commit
934c698f3f
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.venv
|
@ -3,8 +3,10 @@ from dotenv import load_dotenv
|
|||||||
from os import getenv
|
from os import getenv
|
||||||
from random import randint
|
from random import randint
|
||||||
from requests import get, post
|
from requests import get, post
|
||||||
|
from sys import argv
|
||||||
|
|
||||||
def load_env():
|
def load_env():
|
||||||
|
load_dotenv()
|
||||||
api_key = getenv('QUOTES_ACCESS_TOKEN')
|
api_key = getenv('QUOTES_ACCESS_TOKEN')
|
||||||
quotes_library = getenv('QUOTES_LIBRARY')
|
quotes_library = getenv('QUOTES_LIBRARY')
|
||||||
if quotes_library.startswith('https',0):
|
if quotes_library.startswith('https',0):
|
||||||
@ -40,6 +42,10 @@ def make_post(headers, payload):
|
|||||||
print('An error occurred: ', e)
|
print('An error occurred: ', e)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
if len(argv) > 0:
|
||||||
|
choice = int(argv[1])
|
||||||
|
else:
|
||||||
|
choice = int(0)
|
||||||
api_key, quote_file = load_env()
|
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)
|
make_post(headers, payload)
|
||||||
|
6
requirements.txt
Normal file
6
requirements.txt
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user