
Flask 开启服务后,默认是本机访问的,使用localhost:5000可以访问Web服务,但是使用如192.168.1.10这类本机IP地址却访问不了。
启动Falsk服务后信息如下,
1 2 3 4 5 6 7 8 9
|
* Serving Flask app "app" (lazy loading) * Environment: production WARNING: Do not use the development server in a production environment. Use a production WSGI server instead. * Debug mode: on * Restarting with stat * Debugger is active! * Debugger PIN: 228-080-042 * Running on ://127.0.0.1:5000/ (Press CTRL+C to quit)
|
除本机外是不能访问的,需要在run参数中设置,端口自定,主机为0.0.0.0
1
|
app.run(host='0.0.0.0', port=5000)
|
再次启动后就可以了。
1 2 3 4 5 6 7 8 9
|
* Serving Flask app "app" (lazy loading) * Environment: production WARNING: Do not use the development server in a production environment. Use a production WSGI server instead. * Debug mode: on * Restarting with stat * Debugger is active! * Debugger PIN: 228-080-042 * Running on ://0.0.0.0:5000/ (Press CTRL+C to quit)
|
近期评论