我是 Flask 新手,如果问题听起来微不足道,请不要介意。
我有一个 Flask 应用程序(不是我编写的),当我直接连接到网络时,它可以在本地计算机和远程计算机上正常工作。
但是当我通过 VPN 连接到该应用程序时,它不起作用。我可以在那台机器上进行 ssh 访问,也可以访问同一台机器上运行的其他服务器。它是物理机而不是虚拟机
app = Flask(__name__)
def loadAppVariables():
mc = pylibmc.Client(["127.0.0.1"], binary=True,
behaviors={"tcp_nodelay": True,
"ketama": True});
app.mc=mc
def initApp():
app.fNet= {some object }
mc = pylibmc.Client(["127.0.0.1"], binary=True,
behaviors={"tcp_nodelay": True,
"ketama": True});
app.mc=mc;
@app.route('/classify', methods=['POST'])
def classify():
# We will save the file to disk for possible data collection.
imagefile = request.files['imagefile']
processImageFile(imagefile)
@app.route('/')
def index():
return render_template('cindex.html', has_result=False)
@app.before_request
def before_request():
loadAppVariables()
@app.teardown_request
def teardown_request(exception):
storeAppVariables()
if __name__ == '__main__':
initApp();
app.run(debug=False,host='0.0.0.0')
我正在运行最新的 Flask 版本和 python 2.7。谁能建议这里可能出了什么问题吗?
您似乎想通过另一个网络访问本地启用的烧瓶。0.0.0.0
ip 是从不同的机器连接到flask,但在同一网络范围内。因此,如果您的 IP 不在同一范围内,则会失败。
如果您想从互联网访问您的网页,您应该考虑deploy http://flask.pocoo.org/docs/0.12/deploying/你的网络应用程序。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)