123456789101112131415161718192021222324252627282930 |
- import json
- import sys
- from pathlib import Path
- from flask import Flask
- from flask_migrate import Migrate
- from flask_sqlalchemy import SQLAlchemy
- print('- Loading settings')
- with open('settings.json') as file:
- settings = json.load(file)
- app = Flask(__name__)
- if "unittest" in sys.modules:
- # creates an in-memory DB
- db_file = ""
- app.logger.setLevel("CRITICAL")
- else:
- db_file = Path.cwd() / settings['database']
- app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite:///{db_file}"
- app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
- db = SQLAlchemy(app)
- db.session().execute("PRAGMA foreign_keys=ON")
- migrate = Migrate(app, db)
|