File size: 686 Bytes
35805d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from dotenv import load_dotenv, find_dotenv
import os

def getenvvar(varname):
    # needed to strip env var of any remaining quotes - might be added by deployment scripts
    val = os.environ.get(varname)
    if val is None:
        f"Environment variable {varname} not found"
    else:
        return val.strip('"').strip("'")

def load_credentials():
    load_dotenv(find_dotenv())  # take environment variables from .env.
    apikey = getenvvar("WXAI_APIKEY")
    apiendpoint = getenvvar("WXAI_ENDPOINT")
    projectid = getenvvar("WXAI_PROJECT")
    status = apiendpoint is not None and apikey is not None and projectid is not None
    return status, apiendpoint, apikey, projectid