error handling if no .env file is provided

This commit is contained in:
Believethehype
2023-12-19 11:36:25 +01:00
parent 3043c188f5
commit 70e684f0b1
4 changed files with 18 additions and 25 deletions

View File

@@ -146,6 +146,10 @@ def playground():
if __name__ == '__main__':
env_path = Path('.env')
if not env_path.is_file():
with open('.env', 'w') as f:
print("Wrting new .env file")
f.write('')
if env_path.is_file():
print(f'loading environment from {env_path.resolve()}')
dotenv.load_dotenv(env_path, verbose=True, override=True)