Django-like settings for Sanic
Project description
sanic-conf
Django-like settings for Sanic
Quick Start
Installation
pip install sanic-conf
Create settings.py
file
sanic
├─ app.py
└─ settings.py
Fill out the project settings
# settings.py
PROXIES_COUNT = 1
REAL_IP_HEADER = 'X-Real-IP'
Apply to Sanic config
import os
from sanic import Sanic
app = Sanic(__name__, load_env=False)
# settings
os.environ.setdefault('SANIC_SETTINGS_MODULE', 'settings')
app.config.from_object('sanic_conf.Settings')
Advanced usage
Note that you can use django-environ with Sanic.
pip install django-environ
# settings.py
import environ
env = environ.Env(
DEBUG=(bool, False)
)
# reading .env file
environ.Env.read_env()
# False if not in os.environ
DEBUG = env('DEBUG')
PROXIES_COUNT = 1
REAL_IP_HEADER = 'X-Real-IP'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sanic-conf-0.0.1.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for sanic_conf-0.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca9a64037a35d84338557332060405e870403bab133bdad6fc25bed67db58fe8 |
|
MD5 | 86ab6d94a8ba1b4982f9e39a1299568d |
|
BLAKE2b-256 | d19242ee271b2a8237148759638ec594664f8d7e55d1dd186c12821e1f8e272f |