Why can't I change the host and port that my Flask app runs on?

前端 未结 5 554
自闭症患者
自闭症患者 2020-11-30 08:32

I want to change the host and port that my app runs on. I set host and port in app.run, but the flask run command still r

5条回答
  •  时光取名叫无心
    2020-11-30 08:53

    The flask command is separate from the flask.run method. It doesn't see the app or its configuration. To change the host and port, pass them as options to the command.

    flask run -h localhost -p 3000
    

    Pass --help for the full list of options.

    Setting the SERVER_NAME config will not affect the command either, as the command can't see the app's config.


    Never expose the dev server to the outside (such as binding to 0.0.0.0). Use a production WSGI server such as uWSGI or Gunicorn.

    gunicorn -w 2 -b 0.0.0.0:3000 myapp:app
    

提交回复
热议问题