app.run(host='0.0.0.0',port=9090)
时间: 2024-01-15 14:53:49 浏览: 186
这是 Flask 框架中用于启动应用程序的代码,其中 host 参数指定了应用程序监听的 IP 地址,'0.0.0.0' 表示监听所有的网络接口;port 参数指定了应用程序监听的端口号,这里指定的是 9090 端口。这样,当应用程序启动后,用户可以通过浏览器或者其他 HTTP 客户端访问该应用程序,例如:http://0.0.0.0:9090。
相关问题
app.run(debug=True,host='0.0.0.0')和app.run(debug=True,host='0.0.0.0',port = 80)区别是什么
`app.run(debug=True, host='0.0.0.0')` 和 `app.run(debug=True, host='0.0.0.0', port=80)` 的区别在于端口号的不同。
`app.run(debug=True, host='0.0.0.0')` 表示将 Flask 应用程序运行在本地的默认端口号上(一般为 5000),并且可以通过局域网或公网访问。这种情况下,如果有多个 Flask 应用程序在同一台计算机上运行,它们将使用不同的端口号来区分彼此。
`app.run(debug=True, host='0.0.0.0', port=80)` 表示将 Flask 应用程序运行在本地的 80 端口上,并且可以通过局域网或公网访问。在浏览器中访问应用程序时,不需要指定端口号。这种情况下,如果有多个 Flask 应用程序在同一台计算机上运行,它们将会互相冲突,因为它们都使用同一个端口号。
因此,当你只需要在本地运行一个 Flask 应用程序时,可以使用默认的端口号,而如果需要将应用程序部署到公网上,则需要指定一个独立的端口号。
app.run(host='0.0.0.0',port=9090)的返回值是多少
在 Flask 框架中,`app.run()` 函数没有返回值,它主要是用于启动 Flask 应用程序,将应用程序监听在指定的主机名和端口号上,以便接受来自客户端的请求并做出响应。在启动 Flask 应用程序时,可以通过设置 host 和 port 参数来指定应用程序监听的主机名和端口号。如果应用程序启动失败,`app.run()` 函数会抛出异常。
阅读全文
相关推荐

















