def app(): return create_app(get_config('test'))
def when_valid(): config = get_config('production') expect(config.ENV) == 'production'
def when_unknown(): with expect.raises(AssertionError): get_config('unknown')
def when_empty(): with expect.raises(AssertionError): get_config('')
def when_extended(): config = get_config('staging') expect(config.ENV) == 'staging'
import os from flask_script import Manager, Server from demo_project.settings import get_config from demo_project.factory import create_app def find_assets(): """Yield paths for all static files and templates.""" for name in ['static', 'templates']: directory = os.path.join(app.config['PATH'], name) for entry in os.scandir(directory): if entry.is_file(): yield entry.path config = get_config(os.getenv('FLASK_ENV')) app = create_app(config) server = Server(extra_files=find_assets()) manager = Manager(app) manager.add_command('run', server) if __name__ == '__main__': manager.run()