在Windows上与服务生一起提供Flask应用程序 [英] Serving Flask app with waitress on windows
本文介绍了在Windows上与服务生一起提供Flask应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用以下代码运行网络服务器
I am able to run a webserver using the following code
from flask import Flask
from waitress import serve
app = Flask(__name__, static_url_path='/static')
...
serve(app, port=8080)
问题是我只能从运行它的计算机上访问它,如果我尝试使用ipv4 ip访问它,则它不起作用.我错过了一步吗?
The problem is that I can access it only from the machine where it is running, if I try to access it using the ipv4 ip, it doesn't work. Am I missing a step?
推荐答案
简单的示例,请尝试!
希望对您有帮助.
Simple example,try it!
I hope it will help you.
app1.py
from flask import Flask
app = Flask(__name__)
# app.run(host='0.0.0.0', port=8080,debug=True)
waitress_server.py
waitress_server.py
from waitress import serve
import app1
serve(app1.app, host='0.0.0.0', port=8080)
然后在命令下运行
python waitress_server.py
这篇关于在Windows上与服务生一起提供Flask应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文