powermeter/app/__init__.py
Finn Christiansen c554194fb5
All checks were successful
/ Python-PEP8 (push) Successful in 12s
💚 Fix PEP8 warnings
2024-10-11 22:31:28 +02:00

30 lines
651 B
Python

from flask import Flask
from flask_smorest import Api
from flask_marshmallow import Marshmallow
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
db = SQLAlchemy()
ma = Marshmallow()
def create_app(cfg='default'):
from config import config
app = Flask(__name__)
app.config.from_object(config[cfg])
app.url_map.strict_slashes = False
config[cfg].init_app(app)
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
from . import resources
api = Api()
api.init_app(app)
db.init_app(app)
ma.init_app(app)
Migrate(app, db)
resources.register_blueprints(api)
return app