Question: For some reason I'm getting a `Internal Server Error 500` on `nginx` when I upload a `png` file to my site. The site works with a `jpg` or `jpeg` file. I am getting nothing in the error log at all. My mime.types holds the following:

```
image/jpeg                            jpeg jpg;
image/png                             png;

```

Since I'm getting no feedback at all, I have nothing to place here as more information on the error. The only `nginx.conf` directives with regards to uploads is this:

```
client_max_body_size    12M;

```

I am guessing it is `nginx` that's having this issue because the application is handling the other file types (`jpg`, `jpeg`) and error reporting shows I'm not even getting to my `route` in `Sinatra`. I've looked for some kind of file type directives in the `nginx` directives list, and found nothing. 

How can I get this file type to be received properly? Why is `nginx` not happy with this file submission?

Answer: 
Why can't you add a `create_app()` function within your `__init__.py` file for your app package and register your blueprints within this function? Then you can just import the `current_app` variable in your desired blueprint and reference the `current_app` variable as necessary. Something along the lines of:

**\_\_init\_\_.py**:

```
 # .... other package initialization code

 def create_app(config_class=Config):
    app = Flask(__name__)
    app.config.from_object(Config)

    # initialization of important app components
    # database, login_manager, mail, etc....
    db.init_app(app)

    # register blueprints
    from app.acuity.routes import <acuity_blueprint_variable>
    from app.main.routes import blueprint
    app.register_blueprint(<acuity_blueprint_variable>)
    app.register_blueprint(blueprint)

return app

```

**main/routes.py**:

```
   # import your flask dependencies then just reference current_app where necessary
   from flask import request, redirect, url_for, render_template, current_app, Response

   blueprint = flask.Blueprint('main', __name__)

   @blueprint.route("/api", methods=["GET"])
   def list_routes():
       result = []
       for rt in current_app.url_map.iter_rules():
           result.append({
               "methods": list(rt.methods),
               "route": str(rt)
        })

    return flask.jsonify({"routes": result, "total": len(result)})

```

In the example above, I showed using `current_app` within the `main` blueprint `list_routes` endpoint which simply shows the routes defined for your application. Note within your `create_app` function I am importing the blueprint variable I created within `main.routes` called 'blueprint' and registering this blueprint to the app so references to `current_app` variable can be made inside this blueprint's routes.

Hopefully that makes sense!
It may not be the most elegant solution, but you can place the items inside of your create\_app (app factory) function in **init**.py. 

If you can't do that, as per the Flask docs - you should move the code into a view function or CLI command.