Added config switching
This commit is contained in:
parent
5a5f307c33
commit
f272323480
|
@ -1,11 +1,11 @@
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
|
||||||
from config import Config
|
from config import config
|
||||||
from app.blueprints import blueprints
|
from app.blueprints import blueprints
|
||||||
from app.extensions import db, migrate
|
from app.extensions import db, migrate
|
||||||
from app.celery import celery_init_app
|
from app.celery import celery_init_app
|
||||||
|
|
||||||
def create_app(config_class=Config):
|
def create_app(config_class=config):
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config.from_object(config_class)
|
app.config.from_object(config_class)
|
||||||
|
|
||||||
|
|
14
config.py
14
config.py
|
@ -2,8 +2,8 @@ import os
|
||||||
|
|
||||||
basedir = os.path.abspath(os.path.dirname(__file__))
|
basedir = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
|
||||||
class Config:
|
|
||||||
SECRET_KEY = os.environ.get('SECRET_KEY')
|
class ProductionConfig:
|
||||||
SQLALCHEMY_DATABASE_URI = f"postgresql://{os.environ.get('POSTGRES_USER')}:{os.environ.get('POSTGRES_PASSWORD')}@postgres/{os.environ.get('POSTGRES_DB')}"
|
SQLALCHEMY_DATABASE_URI = f"postgresql://{os.environ.get('POSTGRES_USER')}:{os.environ.get('POSTGRES_PASSWORD')}@postgres/{os.environ.get('POSTGRES_DB')}"
|
||||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||||
CELERY = dict(
|
CELERY = dict(
|
||||||
|
@ -12,3 +12,13 @@ class Config:
|
||||||
task_ignore_result=True,
|
task_ignore_result=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class DebugConfig:
|
||||||
|
SQLALCHEMY_DATABASE_URI = f"postgresql://postgres:123456789@localhost:5432/paper"
|
||||||
|
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||||
|
CELERY = dict(
|
||||||
|
broker_url="redis://localhost:6379/0",
|
||||||
|
result_backend="redis://localhost:6379/0",
|
||||||
|
task_ignore_result=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
config = DebugConfig
|
Loading…
Reference in New Issue