Updating project structure: Adding config file
This commit is contained in:
parent
36a2c61048
commit
4933d70b2c
2 changed files with 61 additions and 10 deletions
|
@ -22,19 +22,24 @@ import flask
|
||||||
from src.models import db
|
from src.models import db
|
||||||
from views.errors import error_pages
|
from views.errors import error_pages
|
||||||
from views.scoreboard import scoreboard
|
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
|
def create_app(config_name):
|
||||||
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'database.sqlite')
|
app = flask.Flask(__name__)
|
||||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
app.config.from_object(config[config_name])
|
||||||
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
|
|
||||||
db.init_app(app)
|
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__":
|
if __name__ == "__main__":
|
||||||
app.register_blueprint(scoreboard)
|
|
||||||
app.register_blueprint(error_pages)
|
|
||||||
app.run("0.0.0.0")
|
app.run("0.0.0.0")
|
||||||
|
|
46
src/config.lock.py
Normal file
46
src/config.lock.py
Normal 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
|
||||||
|
}
|
Loading…
Reference in a new issue