Environment variables
Environment variables is achieved programmatically using Stores. This allows to use custom types.
Note
This requires the use of a main file.
For example:
from zapy.store import use_store
store = use_store()
store.my_var = 'foo'
# or
store['my_var'] = 'bar'
It's recommended to have a separate module to load environment variables. In this way, it can be utilized Chaining. For example:
from zapy.utils import module
if __name__ == '__main__':
setup_store = module.load_module('./store.py')
from zapy import server
import store
server.start_server()
from zapy.store import use_store
store = use_store()
store.my_var = 'foo'
Using files
As it's plain Python, you can organize in the way it fits the best for your project. Here are some ideas:
- Use a
.py
file - Use a
.env
file - Use a
.yaml
file - Use
os.environ
- Split on multiple files for each environment
- Have a base file, and extend for each environment
Just be careful of keeping your credentials safe.