Skip to main content

Django-like settings for Sanic

Project description

sanic-conf

Django-like settings for Sanic

PyPI Build Status

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
from sanic_conf import settings

app = Sanic(__name__, load_env=False)

# settings
os.environ.setdefault('SANIC_SETTINGS_MODULE', 'settings')
app.config.update_config(settings)

Environment variables

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


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.7.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

sanic_conf-0.0.7-py2.py3-none-any.whl (3.5 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page