using .env
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -8,6 +8,8 @@ node_modules/
|
|||||||
# Created by https://www.gitignore.io/api/python
|
# Created by https://www.gitignore.io/api/python
|
||||||
# Edit at https://www.gitignore.io/?templates=python
|
# Edit at https://www.gitignore.io/?templates=python
|
||||||
|
|
||||||
|
.env
|
||||||
|
|
||||||
### Python ###
|
### Python ###
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 1,
|
"execution_count": 5,
|
||||||
"id": "ab869d03-ed90-4c48-affe-02eb74938022",
|
"id": "ab869d03-ed90-4c48-affe-02eb74938022",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -18,6 +18,70 @@
|
|||||||
"import os\n",
|
"import os\n",
|
||||||
"print(os.getcwd())"
|
"print(os.getcwd())"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 2,
|
||||||
|
"id": "10f377d9-24ec-4d64-8dd5-2cfbe14a0245",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# /home/changcl/apps/jupyter\n",
|
||||||
|
"# uv add python-dotenv\n",
|
||||||
|
"from dotenv import load_dotenv"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 3,
|
||||||
|
"id": "149cbe5b-8365-47c1-a88b-9726865ef16a",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": [
|
||||||
|
"True"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 3,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"load_dotenv()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 6,
|
||||||
|
"id": "64fe12a2-a517-4336-adfc-4965531b19d9",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"database_url = os.getenv(\"DATABASE_URL\")\n",
|
||||||
|
"api_key = os.getenv(\"API_KEY\")"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 7,
|
||||||
|
"id": "9fb9cbb7-e13e-44f9-84c7-9124a1274ede",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Database URL: postgresql://user:password@host:port/database\n",
|
||||||
|
"API Key: your_secret_api_key\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"print(f\"Database URL: {database_url}\")\n",
|
||||||
|
"print(f\"API Key: {api_key}\")"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
Reference in New Issue
Block a user