Gunicorn Internal Server Error
Question: I'm setting up Gunicorn with my Flask application. I have the following file
structure:

    
    
    Flask/
      run.py
      myapp/
        __init__.py
        views/
          homepage/
            __init__.py
            homepage.py
          login/
            __init__.py
            login.py
          blog/
            __init__.py
            blog.py
    

The `run.py` file imports the app instance in `Flask/myapp/__init__.py` and
runs it like so:

    
    
    from myapp import app
    def run():
      app.run()
    

Using the command line, I run `gunicorn run:run` and the website starts up. I
go to the website and I get an internal server error stating this:

    
    
    [2015-09-14 19:00:41 +0100] [35529] [ERROR] Error handling request
    Traceback (most recent call last):
      File "/Users/pavsidhu/.virtualenvs/environment/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 130, in handle
        self.handle_request(listener, req, client, addr)
      File "/Users/pavsidhu/.virtualenvs/environment/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 171, in handle_request
        respiter = self.wsgi(environ, resp.start_response)
    TypeError: run() takes no arguments (2 given)
    

What is the issue? Thanks.


Answer: You're supposed to pass [a WSGI callable to `gunicorn`](http://gunicorn-
docs.readthedocs.org/en/latest/run.html#gunicorn). As it turns out `app` is
one, but your `run` function isn't.

So, instead of running `gunicorn run:run`, run: `gunicorn run:app`.

