Reputation: 81
i am running a flask application, the app is running but not following the configurations i have set.This is the config file
import os
class Config(object):
"parent configuration class"
DEBUG= True
class DevelopmentConfig(Config):
"Configurations for Development"
DEBUG = True
connectionVariables="dbname='store-manager' user='postgres' password="1235" host='localhost' port='5432'"
os.environ['ENVIRONMENT']='development'
class TestingConfig(Config):
"""Configurations for Testing,"""
TESTING = True
DEBUG = True
connectionVariables="dbname='store-manager-test' user='postgres' password="1235" host='localhost' port='5432'"
os.environ['ENVIRONMENT']='testing'
app_config = {
'development': DevelopmentConfig,
'testing': TestingConfig
}
Whenever i run the app it runs on testing mode even when i have specified development, however, if i remove the testing configuration, it runs on development environment. This is how am creating the app
from flask import Flask
from flask_restful import Api
from instance.config import app_config
from connection import DbBase
def create_app(config_name):
app = Flask(__name__)
app.config.from_object(app_config[config_name])
return app
This is how am running it.
import os
from app import create_app
config_name = 'development'
app = create_app(config_name)
# method to run app.py
if __name__ == '__main__':
app.run()
Upvotes: 0
Views: 332
Reputation: 1057
Depending on how you're actually running it and on what platform, you need to be sure to specify the location of the config.file.
export YOURAPPLICATION_SETTINGS=/path/to/settings.cfg
or for windows
set YOURAPPLICATION_SETTINGS=\path\to\settings.cfg
I'm not seeing it in the above description, so this may the the problem.
Flask Doc on using a config File
Upvotes: 1