From bf106fa19efbf1549cc22d54edef4a17c9b3cf3a Mon Sep 17 00:00:00 2001 From: thomaswoehlke <thomas.woehlke@gmail.com> Date: Wed, 17 Feb 2021 11:25:22 +0100 Subject: [PATCH] ### 0.0.17 Release * Fixed #123 split RkiBundeslaenderService into two Services, one for bundeslaender and one for landkreise * Fixed #128 add fields from csv to RkiLandkreiseImport * Fixed #139 refactor RkiBundeslaenderServiceDownload to new method scheme introduced 07.02.2021 * Fixed #140 move WhoImport to RKI in: rk_service_import.py * Fixed #125 implement RkiLandkreise * Fixed #126 implement RkiBundeslaenderImport ### 0.0.18 Release * Fixed #39 SQLalchemy instead of SQL: AllModelClasses.remove_all() * Fixed #40 SQLalchemy instead of SQL: EcdcImport.get_date_rep() * Fixed #41 SQLalchemy instead of SQL: EcdcImport.get_countries_of_continent() * Fixed #107 SQLalchemy instead of SQL in: EcdcImport.get_countries_of_continent * Fixed #109 SQLalchemy instead of SQL in: EcdcImport.get_date_rep * Fixed #110 SQLalchemy instead of SQL in: EcdcImport.get_continent --- src/database.py | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/database.py b/src/database.py index d6cce5df..e9f24fe4 100644 --- a/src/database.py +++ b/src/database.py @@ -1,27 +1,36 @@ from flask import Flask from flask_cors import CORS +from flask_bs4 import Bootstrap from flask_sqlalchemy import SQLAlchemy from logging.config import dictConfig from flask_admin import Admin -app = Flask('app') -CORS(app) -app.config.from_object("config") -port = app.config['PORT'] -ITEMS_PER_PAGE = app.config['ITEMS_PER_PAGE'] -DB_URL = 'postgresql+psycopg2://{user}:{pw}@{url}/{db}'.format( - user=app.config['POSTGRES_USER'], - pw=app.config['POSTGRES_PW'], - url=app.config['POSTGRES_URL'], - db=app.config['POSTGRES_DB']) -app.config['SQLALCHEMY_DATABASE_URI'] = DB_URL -app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False # silence the deprecation warning -run_run_with_debug = app.config['APP_DEBUGGER_ACTIVE'] -app.config['FLASK_ADMIN_SWATCH'] = 'superhero' + +def create_app(): + app = Flask('app') + CORS(app) + Bootstrap(app) + app.config.from_object("config") + DB_URL = 'postgresql+psycopg2://{user}:{pw}@{url}/{db}'.format( + user=app.config['POSTGRES_USER'], + pw=app.config['POSTGRES_PW'], + url=app.config['POSTGRES_URL'], + db=app.config['POSTGRES_DB']) + app.config['SQLALCHEMY_DATABASE_URI'] = DB_URL + app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False # silence the deprecation warning + app.config['FLASK_ADMIN_SWATCH'] = 'superhero' + return app + + +app = create_app() admin = Admin(app, name='covid19admin', template_mode='bootstrap4') db = SQLAlchemy(app) db.create_all() +port = app.config['PORT'] +run_run_with_debug = app.config['APP_DEBUGGER_ACTIVE'] +ITEMS_PER_PAGE = app.config['ITEMS_PER_PAGE'] + my_logging_config = { 'version': 1, 'formatters': {'default': { -- GitLab