42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
from flask import Flask
|
|
from flask_bootstrap import Bootstrap5
|
|
from datetime import datetime
|
|
|
|
from app.views import register_views
|
|
from app.api import register_api
|
|
from app.config import load_config
|
|
from app.filters import register_filters
|
|
|
|
from app.logging_config import init_logger
|
|
|
|
def create_app():
|
|
app = Flask(__name__)
|
|
|
|
config = load_config()
|
|
|
|
app.config['SECRET_KEY'] = config['DEFAULT']['SECRET_KEY']
|
|
|
|
# Move bootstrap settings to root level
|
|
for key, value in config.get('BOOTSTRAP', {}).items():
|
|
app.config[key.upper()] = value
|
|
|
|
bootstrap = Bootstrap5(app)
|
|
|
|
# Store the entire config in Flask app
|
|
app.config.update(config)
|
|
|
|
# Initialize other settings
|
|
app.config['SCRAPING_ACTIVE'] = False
|
|
app.config['SCRAPING_THREAD'] = None
|
|
app.config['DATA_FILE_NAME'] = None
|
|
app.config['LOG_FILE_NAME'] = "log/" + datetime.now().strftime('%Y-%m-%d-%H-%M') + '.log'
|
|
|
|
# Initialize logging
|
|
app.logger = init_logger(app.config)
|
|
|
|
# Register routes
|
|
register_views(app)
|
|
register_api(app)
|
|
register_filters(app)
|
|
|
|
return app |