通过VPN连接到烧瓶应用程序

时间:2017-07-03 15:50:52

标签: python flask

我是Flask的新手,如果问题听起来微不足道,请不要介意。 我有一个Flask应用程序(不是由我编写的),当我直接连接到网络时,它可以在本地计算机以及远程计算机上正常工作。

但是当我通过VPN连接到应用程序时,它无法正常工作。我能够在该机器上ssh以及访问在同一台机器上运行的其他服务器。它是物理机器而不是VM

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。任何人都可以建议这里可能有什么问题吗?

1 个答案:

答案 0 :(得分:1)

您似乎希望通过其他网络访问本地启用的刻录机。 0.0.0.0 ip是从不同的机器连接到烧瓶,但在同一网络范围内。因此,如果您的IP不在同一范围内,则会失败。

如果您想从互联网访问您的网页,您应该考虑deploy您的网络应用。

相关问题