python-dotenv icon indicating copy to clipboard operation
python-dotenv copied to clipboard

feat: add with_env param in dotenv_values

Open ramwin opened this issue 3 years ago • 3 comments

ramwin avatar Mar 08 '22 13:03 ramwin

@theskumar could you please check this pr when you have time?

ramwin avatar Apr 05 '22 09:04 ramwin

This feels more like a feature blot and I'm curious to know your use case for this.

theskumar avatar Apr 05 '22 10:04 theskumar

In my server, there are many deployed jobs. For example job a and job b.
In the beginning, I want to deploy job a and job b in the same server to save money, but I want to keep it flexible so I bind domain name a.ramwin.com and b.ramwin.com to the same server. And job a handle the requests whose url is a.ramwin.com and job b handle the requests whose url is b.ramwin.com. So both job a and job b use the same code like this:

my_domain = dotenv_values(with_env=True)
assert request.domain == my_domain, "I shouldn't accept the wrong request, please config your proxy server"

By default the job process should get the domain name from host, but you can configure it with custom .env file.

ramwin avatar Jun 20 '22 01:06 ramwin