Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dldevinc/sanic-conf
Django-like settings for Sanic
https://github.com/dldevinc/sanic-conf
configuration sanic
Last synced: 25 days ago
JSON representation
Django-like settings for Sanic
- Host: GitHub
- URL: https://github.com/dldevinc/sanic-conf
- Owner: dldevinc
- License: bsd-3-clause
- Created: 2020-10-01T05:47:20.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-11T06:38:17.000Z (about 4 years ago)
- Last Synced: 2024-09-23T01:18:14.177Z (3 months ago)
- Topics: configuration, sanic
- Language: Python
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# sanic-conf
Django-like settings for Sanic[![PyPI](https://img.shields.io/pypi/v/sanic-conf.svg)](https://pypi.org/project/sanic-conf/)
[![Build Status](https://travis-ci.org/dldevinc/sanic-conf.svg?branch=master)](https://travis-ci.org/dldevinc/sanic-conf)## Quick Start
Installation
```
pip install sanic-conf
```Create `settings.py` file
```
sanic
├─ app.py
└─ settings.py
```Fill out the project settings
```
# settings.pyPROXIES_COUNT = 1
REAL_IP_HEADER = 'X-Real-IP'
```Apply to Sanic config
```python
import os
from sanic import Sanic
from sanic_conf import settingsapp = 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](https://github.com/joke2k/django-environ)
with Sanic.```
pip install django-environ
``````
# settings.pyimport 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'
```