23 lines
595 B
Python
23 lines
595 B
Python
from flask import Flask
|
|
from flask_sqlalchemy import SQLAlchemy
|
|
from flask_migrate import Migrate
|
|
from config import app_config
|
|
|
|
|
|
db = SQLAlchemy()
|
|
def create_app(config_name):
|
|
app = Flask(__name__, instance_relative_config=True)
|
|
app.config.from_object(app_config[config_name])
|
|
app.config.from_pyfile('config.py')
|
|
db.init_app(app)
|
|
migrate = Migrate(app, db)
|
|
|
|
from app import models
|
|
|
|
from .api import api as api_blueprint
|
|
from .site import site as site_blueprint
|
|
app.register_blueprint(api_blueprint)
|
|
app.register_blueprint(site_blueprint)
|
|
|
|
return app
|