Updating project structure: Adding config file

This commit is contained in:
Denis-Cosmin Nutiu 2017-04-13 16:58:40 +03:00
parent 36a2c61048
commit 4933d70b2c
2 changed files with 61 additions and 10 deletions

View file

@ -22,19 +22,24 @@ import flask
from src.models import db
from views.errors import error_pages
from views.scoreboard import scoreboard
from config import config
# General Configurations
app = flask.Flask(__name__)
basedir = os.path.abspath(os.path.dirname(__file__))
# Database Configuration
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'database.sqlite')
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
db.init_app(app)
def create_app(config_name):
app = flask.Flask(__name__)
app.config.from_object(config[config_name])
config[config_name].init_app(app)
db.init_app(app)
app.register_blueprint(scoreboard)
app.register_blueprint(error_pages)
return app
app = create_app('default')
if __name__ == "__main__":
app.register_blueprint(scoreboard)
app.register_blueprint(error_pages)
app.run("0.0.0.0")

46
src/config.lock.py Normal file
View file

@ -0,0 +1,46 @@
"""
Author: Denis Nutiu <denis.nutiu@gmail.com>
This file is part of scoreboard-benchmark.
scoreboard-benchmark is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
scoreboard-benchmark is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with scoreboard-benchmark . If not, see <http://www.gnu.org/licenses/>.
"""
import os
basedir = os.path.abspath(os.path.dirname(__file__))
class Config:
SQLALCHEMY_TRACK_MODIFICATIONS = False
SQLALCHEMY_COMMIT_ON_TEARDOWN = True
@staticmethod
def init_app(app):
pass
class DevelopmentConfig(Config):
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'database.sqlite')
class ProductionConfig(Config):
pass
class TestingConfig(Config):
pass
config = {
'development': DevelopmentConfig,
'production' : ProductionConfig,
'testing' : TestingConfig,
'default' : DevelopmentConfig
}