Skip to content

Commit 9458589

Browse files
committed
adding envs
1 parent 475f6b8 commit 9458589

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

.circleci/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ commands:
3333
- run:
3434
name: Install Test Dependencies
3535
command: pip install -r requirements.txt
36+
- run:
37+
name: Create ENV file
38+
command: env > .env
3639
package-lambda:
3740
description: "Packages the Python into a zip file."
3841
steps:

app/core/__init__.py

Whitespace-only changes.

app/core/config.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from pydantic import BaseSettings
2+
3+
4+
class Settings(BaseSettings):
5+
API_V1_STR: str = "/api/v1"
6+
PROJECT_NAME: str = "serverless-fastapi-lambda"
7+
SECRET_KEY: str
8+
9+
10+
class Config:
11+
case_sensitive = True
12+
env_file = ".env"
13+
14+
settings = Settings()

app/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
from fastapi import FastAPI
22

33
from app.api.api_v1.api import router as api_router
4+
from app.core.config import settings
45
from mangum import Mangum
56

67
app = FastAPI()
78

89

910
@app.get("/")
1011
async def root():
11-
return {"message": "Deployed with CircleCi!"}
12+
return {"message": f"Secret Key: {settings.SECRET_KEY}"}
1213

1314

14-
app.include_router(api_router, prefix="/api/v1")
15+
app.include_router(api_router, prefix=settings.API_V1_STR)
1516
handler = Mangum(app)

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ MarkupSafe==1.1.1
2121
orjson==3.3.0
2222
promise==2.3
2323
pydantic==1.6.1
24+
python-dotenv==0.14.0
2425
python-multipart==0.0.5
2526
PyYAML==5.3.1
2627
requests==2.24.0

0 commit comments

Comments
 (0)