26 lines
706 B
Python
26 lines
706 B
Python
from flask import Flask
|
|
from flask_sqlalchemy import SQLAlchemy
|
|
from flask_wtf.csrf import CSRFProtect
|
|
import os
|
|
|
|
db = SQLAlchemy()
|
|
csrf = CSRFProtect()
|
|
|
|
def create_app():
|
|
app = Flask(__name__)
|
|
app.config['SECRET_KEY'] = 'you-will-never-guess'
|
|
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(os.path.abspath(os.path.dirname(__file__)), '..', 'instance', 'sport_inventory.db')
|
|
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
|
|
|
db.init_app(app)
|
|
csrf.init_app(app)
|
|
|
|
from . import routes
|
|
app.register_blueprint(routes.bp)
|
|
|
|
with app.app_context():
|
|
db.create_all()
|
|
from .db import init_test_data
|
|
init_test_data()
|
|
|
|
return app |