Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.rst

JSON Environ

Documentation Status

Utilize environment variables from JSON file to configure your Python application. Inspired from django-environ.

Quick Example

Let's assume we have JSON file like:

{
  "SECRET_KEY": "kminvupn=7dbw70e!#njo8qas2bx$tmw$nv1pt$g30&+f4(8c)",
  "DEBUG": true,
  "SSL": false,
  "ALLOWED_HOSTS": [
    "*"
  ],
  "DATABASE": {
    "NAME": "dbname",
    "USER": "dbuser",
    "PASSWORD": "dbsecret"
  }
}

To use JSON Environ in a project:

import os

from json_environ import Environ

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
env_path = os.path.join(BASE_DIR, '.my_env.json')
env = Environ(path=env_path)

SECRET_KEY = env('SECRET_KEY', default="PT09PT0KVXNhZ2UKPT09PT0KClRvI")
DEBUG = env("DEBUG")
ALLOWED_HOSTS = env('ALLOWED_HOSTS')
if env('SSL', default=False) is True:
    SECURE_SSL_REDIRECT = False

DATABASES = {
    'default': {
        'NAME': env("DATABASE:NAME", default="test"),
        'USER': env("DATABASE:USER", default="lms"),
        'PASSWORD': env("DATABASE:PASSWORD", default="123456"),
    }
}

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

About

Utilize environment variables from JSON file to configure your Python application.

Topics

Resources

License

Releases

No releases published

Packages

No packages published
You can’t perform that action at this time.