{ "cells": [ { "cell_type": "markdown", "id": "78f4637d", "metadata": {}, "source": [ "## Setting up Environmental Variables\n", "Setting up environmental variables to hold secret keys is the best way to ensure no secret leaks of sensitive information." ] }, { "cell_type": "markdown", "id": "c3336fd5", "metadata": {}, "source": [ "### Load Environmental Variables\n", "Load environmental variables one of the two following ways\n", "\n", "If set variables using `.env` file :" ] }, { "cell_type": "code", "execution_count": null, "id": "b6fe84f9", "metadata": {}, "outputs": [], "source": [ "import os\n", "from dotenv import load_dotenv\n", "\n", "load_dotenv()\n", "\n", "os.getenv('ENV_KEY_NAME') # Example: 'AZURE_API_KEY'" ] }, { "cell_type": "markdown", "id": "f26123d2", "metadata": {}, "source": [ "If setting environmental variables with `source` or `set` :" ] }, { "cell_type": "code", "execution_count": null, "id": "88c57e05", "metadata": {}, "outputs": [], "source": [ "import os\n", "\n", "os.getenv('ENV_KEY_NAME') # Example: 'AZURE_API_KEY'" ] } ], "metadata": { "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }