feat: introduce pydantic-settings for config definition and validation (#5202)

Co-authored-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
Bowen Liang 2024-06-19 13:41:12 +08:00 committed by GitHub
commit 3cc6093e4b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 772 additions and 227 deletions

View file

@ -2,7 +2,7 @@ from flask import Flask
def init_app(app: Flask):
if app.config.get('API_COMPRESSION_ENABLED', False):
if app.config.get('API_COMPRESSION_ENABLED'):
from flask_compress import Compress
app.config['COMPRESS_MIMETYPES'] = [

View file

@ -6,15 +6,15 @@ redis_client = redis.Redis()
def init_app(app):
connection_class = Connection
if app.config.get('REDIS_USE_SSL', False):
if app.config.get('REDIS_USE_SSL'):
connection_class = SSLConnection
redis_client.connection_pool = redis.ConnectionPool(**{
'host': app.config.get('REDIS_HOST', 'localhost'),
'port': app.config.get('REDIS_PORT', 6379),
'username': app.config.get('REDIS_USERNAME', None),
'password': app.config.get('REDIS_PASSWORD', None),
'db': app.config.get('REDIS_DB', 0),
'host': app.config.get('REDIS_HOST'),
'port': app.config.get('REDIS_PORT'),
'username': app.config.get('REDIS_USERNAME'),
'password': app.config.get('REDIS_PASSWORD'),
'db': app.config.get('REDIS_DB'),
'encoding': 'utf-8',
'encoding_errors': 'strict',
'decode_responses': False