Skip to content

Commit

Permalink
Merge pull request #184 from daniellok-db/change-env
Browse files Browse the repository at this point in the history
fix: only pass .env as default to starlette config if it exists
  • Loading branch information
laurentS committed Feb 5, 2024
2 parents 5c79615 + e2db7e2 commit 4eb45eb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion slowapi/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import inspect
import itertools
import logging
import os
import time
from datetime import datetime
from email.utils import formatdate, parsedate_to_datetime
Expand Down Expand Up @@ -154,8 +155,11 @@ def __init__(

self.logger = logging.getLogger("slowapi")

dotenv_file_exists = os.path.isfile(".env")
self.app_config = Config(
config_filename if config_filename is not None else ".env"
".env"
if dotenv_file_exists and config_filename is None
else config_filename
)

self.enabled = enabled
Expand Down

0 comments on commit 4eb45eb

Please sign in to comment.