How To Secure Variables In Python Using .env File

preview_player
Показать описание
Do you need variables that you don't want to expose in your Python code? Things like usernames, passwords, API tokens and other sensitive data? Does your code need certain variables defined in order to run? Don't statically enter this information, exposing things you don't want people to see. Instead you can call variables from a .env file using the Python Decouple package. I'll show you exactly how to setup your code to be more secure and modular.
00:00 Introduction
00:50 Lookback at using OS Environment Vars
02:22 Example .env file as a helper
03:23 Creating the .env file
04:09 Adding the .env file to .gitignore
04:42 Using decouple in a Python file
06:22 Setting default values in decouple
06:39 Using cast=Csc() to return a list
Рекомендации по теме
Комментарии
Автор

hi, am i understanding this correctly, so the sensitive information is still hardcoded or explicitly written in the .env file, but it's secure because it's not added when you push it on github w .gitignore? also, i never learn this in school, did you learn this yourself or on the job? thanks so much

realworldcodingapplications
Автор

Hello Tod,

Once again, I enjoyed your video – it was really informative. I'm encountering an issue with Visual Studio on Windows 11, as I'm having trouble adding the (Decouple, iCream, and Meraki) libraries. Could you assist me in adding these libraries to my Visual Studio environment on Windows 11, please?

Thank you!

karamalshaltan