@
@
@nixbox2019-11-13 14:42:01
ubuntu
@nixbox, 2019-11-13 14:42:01

How to deploy Flask + Gunicorn if the flask is run via the flask run command?

Hello!
I'm trying to deploy a Flask application using this tutorial
. The problem is that I'm running Flask through the flask run command.
Those. app.run(host='0.0.0.0') doesn't work according to the tutorial.
And to run flask, I use flask run -h 0.0.0.0
The site becomes available on port 5000.
But if you run
gunicorn --bind 0.0.0.0:5000 wsgi:app it gives a
404 error.
Please tell me how can I fix this error?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2019-11-13
_

Those. app.run(host='0.0.0.0') doesn't work according to the tutorial.

What mistake?
$ tree
.
├── main.py
└── wsgi.py

# wsgi.py
from main import app

if __name__ == "__main__":
    app.run()

# main.py
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'У меня работает! Что то ты делаешь не так.'
    
   
if __name__ == "__main__":
    app.run(host='0.0.0.0')

$ gunicorn --bind 0.0.0.0:5000 wsgi:app

M
Mikhail Vasilyev, 2019-11-13
@vasilyevmn

If you are trying to do everything as root, then create a separate user and repeat all the steps.
man working 100%

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question