moves app initialization to correct file
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
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
|
||||
42
app/app.py
42
app/app.py
@@ -1,42 +0,0 @@
|
||||
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 init_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
|
||||
@@ -137,6 +137,3 @@ class Scraper:
|
||||
def stop_scraping(self):
|
||||
self.scraping_active = False
|
||||
current_app.logger.debug("Scraping stopped by user")
|
||||
|
||||
def get_end_time(self):
|
||||
return self.end_time()
|
||||
Reference in New Issue
Block a user