This commit is contained in:
@@ -1,16 +1,30 @@
|
||||
"""init module for the Flask application."""
|
||||
|
||||
import logging
|
||||
|
||||
from flask import Flask
|
||||
|
||||
from app.config import Config
|
||||
from app.database import engine
|
||||
from app.migrations import run_migrations
|
||||
from app.models import Base
|
||||
from app.views import bp
|
||||
from app.migrations import run_migrations
|
||||
|
||||
|
||||
def create_app(test_config=None):
|
||||
def create_app():
|
||||
"""Create and configure an instance of the Flask application."""
|
||||
app = Flask(__name__, instance_relative_config=True)
|
||||
app.config.from_object(Config)
|
||||
|
||||
# Set up Flask logger
|
||||
if not app.logger.handlers:
|
||||
handler = logging.StreamHandler()
|
||||
handler.setFormatter(
|
||||
logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
||||
)
|
||||
app.logger.addHandler(handler)
|
||||
app.logger.setLevel(logging.DEBUG)
|
||||
|
||||
# Create database tables if they don't exist
|
||||
Base.metadata.create_all(engine)
|
||||
|
||||
@@ -21,4 +35,6 @@ def create_app(test_config=None):
|
||||
with app.app_context():
|
||||
run_migrations(app)
|
||||
|
||||
app.logger.info("Application initialized successfully")
|
||||
|
||||
return app
|
||||
|
||||
Reference in New Issue
Block a user