python - Can't connect to Flask API running in VM from Host Maschine
问题描述
I set up a Flask API in a Ubuntu Virtual Maschine (Virtual Box). The VM is on bridged mode. Now i want to request data from the API from the Host System (Windows) and it always tells me that the connection is refused. I tried switching to Host Only but if I try to run the VM with that it instantly crashes. I can ping the VM from Windows but can't get through to Port 5000. I think its either a Virtual Box or a Flask issue. Code of my API:
@app.route('/fnd/<text>', methods=['GET'])
def fnd(text):
print(text)
return jsonify(text)
if __name__ == '__main__':
app.run(host='0.0.0.0',port=5000, Debug=False)
解决方案
推荐阅读
- python - 如何将我自己的模块添加到 dask worker env 以避免没有命名的模块
- typescript - 如何实现类型安全的泛型设置器
- c# - 格式化列表中的值
- python - 从整数获取 Cassandra python 驱动程序中的 murmur3 哈希
- php - redirect()->back() laravel 重定向到根网站
- python - 在 google colab 中安装 LibFMP 包
- algorithm - 有没有特定的算法或方法来解决这个特殊的树问题?
- javascript - 尝试在 React 应用程序中显示 Twitter 关注者的数量
- node.js - 点击表单上的提交按钮后没有任何反应
- flask-sqlalchemy - 如何为 GeoJson 创建 Marshmallow SQL 模式