You can still use the same main() method paradigm. See this starter code below:
app = Flask(your_app_name) # Needs defining at file global scope for thread-local sharing
def setup_app(app):
# All your initialization code
setup_app(app)
if __name__ == '__main__':
app.run(host=my_dev_host, port=my_dev_port, etc='...')
The before_first_request
method could also handle all of those items. But you'll have the delay of setup on first request rather than on server launch.