关于python:Flask App Refusing Connections

Flask App Refusing Connections

我正在运行我的Flask应用程序:
app.run(host='0.0.0.0', debug=True, threaded=True, port=5000, passthrough_errors=False)

但是当我转到 localhost:5000 时,它会收到 ERR_CONNECTION_REFUSED 错误。对正在发生的事情有任何想法吗?
运行时输出为:

1
2
3
4
5
 * Debug mode: on
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 183-524-396

main.py 代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from flask import Flask
from flask_cors import CORS
from test_1.test1 import test1
from test_1.test_files.error_handler import handle_error
# import rollbar

app = Flask(__name__)



@app.route("/")
def hello():
    return"Hello From Error Reporting Test!"

@app.errorhandler(Exception)
def error_handler(error):
    return handle_error(error)

app.register_blueprint(test1, url_prefix='/test1')
cors = CORS(app, resources={r"/test1/*": {"origins":"*"}},
            headers={'Access-Control-Request-Headers', 'Content-Type', 'Access-Control-Allow-Origin'})

if __name__ == '__main__':
    app.run(host='0.0.0.0', debug=True, threaded=True, port=5000, passthrough_errors=False)


它在 docker 容器中运行,我在 docker run 命令中没有端口。确保在 docker run 命令中有 -p 80:80 (将 80 替换为要运行的端口)