Question

No application module specified deploying flask app

Posted November 16, 2020 2.1k views
PythonDeploymentFlask

Hello,
i must say this is my first project. Now I built a flask app, that uses a image classifier. the flask integration works fine locally, but i would like to deploy the app to a lager audience.

i followed the deployment strategy proposed on this git [https://github.com/digitalocean/sample-flask.git](http://) but i get the following error:

number-reader | 12:12:52 usage: gunicorn [OPTIONS] [APP_MODULE]
number-reader | 12:12:52 gunicorn: error: No application module specified.

app = Flask(__name__)

# To setup Bootstrap templates
Bootstrap(app)

# Load trained model
with open("model/classifier.pickle", "rb") as handle:
    classifier = pickle.load(handle)


@app.route('/', methods=['GET', 'POST'])
def load_image():
    if request.method == 'POST':
if __name__ == '__main__':
    app.run(debug=True)

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Try something like this in settings->components->your component:

gunicorn –worker-tmp-dir /dev/shm app:app

The first part is something that digitalocean suggests:
“”“Gunicorn crashes with PermissionError unless launched with a specific argument due to an issue with Gunicorn running in Docker. To resolve, run Gunicorn to use a different location for its temp files by passing this option to the run command: gunicorn –worker-tmp-dir /dev/shm project.wsgi”“”

But it worked for me changing the project.wsgi for app:app (it is what I use on my local machine for testing, since my app file is called app.py)