title: Getting the error Working outside of application context
body: <p>I have struggled with this and read several articles and none seem to work for me I have used &quot;with app.app_context():&quot; right after the Flask call and it does not work.  I am trying to print out the context before it hits the route.  Please help.</p>
  <blockquote>
  <p>Traceback (most recent call last):   File
  &quot;/Users/user1/Documents/PycharmProjects/file_upload2/app/wsgi.py&quot;,
  line 7, in 
  app = create_app()   File &quot;/Users/user1/Documents/PycharmProjects/file_upload2/app/flask_project/<strong>init</strong>.py&quot;,
  line 105, in create_app
  from .uploads import uploads   File &quot;/Users/user1/Documents/PycharmProjects/file_upload2/app/flask_project/uploads.py&quot;,
  line 13, in 
  print(current_app.config.get(&quot;MAX_CONTENT_LENGTH&quot;))   File &quot;/Users/user1/Documents/VENV/file_upload2/lib/python3.9/site-packages/werkzeug/local.py&quot;,
  line 316, in <strong>get</strong>
  obj = instance._get_current_object()  # type: ignore[misc]   File &quot;/Users/user1/Documents/VENV/file_upload2/lib/python3.9/site-packages/werkzeug/local.py&quot;,
  line 513, in _get_current_object
  raise RuntimeError(unbound_message) from None RuntimeError: Working outside of application context.</p>
  </blockquote>
  <pre><code>################################################################################
  # init.py                                                                      #
  ################################################################################
  from flask import Flask
  
  def create_app():
      app = Flask(__name__)
  
      # upload options
      file_mb_max = 100  # in MB
      # app.config['MAX_CONTENT_LENGTH'] = file_mb_max * 1024 * 1024  # tried this
      MAX_CONTENT_LENGTH = file_mb_max * 1024 * 1024
  
      # Register Blueprints
      from .uploads import uploads
      app.register_blueprint(uploads, url_prefix='/upload/')
  
  
      return app
  
  ################################################################################
  # wsgi.py                                                                      #
  ################################################################################
  from flask_project import create_app
  
  app = create_app()
  
  if __name__ == '__main__':
      app.run(debug=True)
  
  ################################################################################
  # uploads.py                                                                   #
  ################################################################################
  from flask import Flask, render_template, request, redirect, url_for, send_from_directory, Blueprint, flash, current_app
  
  uploads = Blueprint('uploads', __name__)
  
  # Check that the upload folder exists
  print(current_app.config['MAX_CONTENT_LENGTH'])
  </code></pre>