Changeset 7be94aa for src/mapservice/server_impl/__init__.py
- Timestamp:
- Apr 11, 2020, 4:46:15 PM (7 years ago)
- Branches:
- debian/bullseye, master
- Children:
- 3db3d13
- Parents:
- da2be70
- File:
-
- 1 edited
-
src/mapservice/server_impl/__init__.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/mapservice/server_impl/__init__.py
rda2be70 r7be94aa 29 29 from .ValidatorWorkaround import ValidatorWorkaround 30 30 31 31 32 def load_config_object(config_name): 32 return import_string('gnuboat_mapservice.server_impl.Config.{}Config'.format(config_name)) 33 return import_string( 34 'gnuboat_mapservice.server_impl.Config.{}Config'.format(config_name) 35 ) 36 33 37 34 38 # determine requested configuration 35 39 config_file = '/etc/gnuboat/mapservice.conf' 36 40 if 'FLASK_ENV' in os.environ and os.environ['FLASK_ENV']: 37 config_object = load_config_object(os.environ['FLASK_ENV'].title())41 config_object = load_config_object(os.environ['FLASK_ENV'].title()) 38 42 elif os.path.isfile(config_file): 39 from . import Config as configure40 config_object = configure.load_from_file(config_file)43 from . import Config as configure 44 config_object = configure.load_from_file(config_file) 41 45 else: 42 config_object = load_config_object('Production')46 config_object = load_config_object('Production') 43 47 44 48 app = connexion.App(__name__, specification_dir='../openapi/') … … 48 52 celery = Celery(__name__, broker=config_object.CELERY_BROKER_URL) 49 53 54 50 55 @application.before_first_request 51 56 def create_database(): 52 @event.listens_for(db.engine, "connect") 53 def load_spatialite_extension(dbapi_conn, connection_record): 54 load_spatialite(dbapi_conn, connection_record) 55 57 @event.listens_for(db.engine, "connect") 58 def load_spatialite_extension(dbapi_conn, connection_record): 59 load_spatialite(dbapi_conn, connection_record) 56 60 57 if flask.current_app.config['CREATE_TEST_DATABASE'] == True: 58 from .demo import DbSetup as demoDbSetup 59 demoDbSetup.setup() 60 else: 61 db_setup() 61 if flask.current_app.config['CREATE_TEST_DATABASE'] == True: 62 from .demo import DbSetup as demoDbSetup 63 demoDbSetup.setup() 64 else: 65 db_setup() 66 62 67 63 68 @application.route("/mapservice/") 64 69 def index(): 65 return render_template('index.html')70 return render_template('index.html') 66 71 67 def setup_app(app_name, config, template_folder = None):68 application.json_encoder = encoder.JSONEncoder69 app.add_api('openapi.yaml', arguments={'title': app_name}, validate_responses=True, strict_validation=True, validator_map={'response': ValidatorWorkaround})70 application.config.from_object(config)71 72 if 'TEMPLATE_FOLDER' in application.config:73 application.template_folder = application.config['TEMPLATE_FOLDER']74 elif template_folder:75 application.template_folder = template_folder76 72 77 db.init_app(application) 78 mail.init_app(application) 79 celery.config_from_object(config) 73 def setup_app(app_name, config, template_folder=None): 74 application.json_encoder = encoder.JSONEncoder 75 app.add_api( 76 'openapi.yaml', 77 arguments={'title': app_name}, 78 validate_responses=True, 79 strict_validation=True, 80 validator_map={'response': ValidatorWorkaround} 81 ) 82 application.config.from_object(config) 83 84 if 'TEMPLATE_FOLDER' in application.config: 85 application.template_folder = application.config['TEMPLATE_FOLDER'] 86 elif template_folder: 87 application.template_folder = template_folder 88 89 db.init_app(application) 90 mail.init_app(application) 91 celery.config_from_object(config)
Note:
See TracChangeset
for help on using the changeset viewer.
