局域网访问 Flask 项目
在服务器上使用http://127.0.0.1:5000可以访问,但是在局域网内通过服务器IP地址访问不了,解决办法为:设置Flask为任何地址均可以访问,post设置为‘0.0.0.0’,
from flask import Flask
app = Flask(__name__)
@app.route('/home')
def index():
return '404'
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5050)
访问 Flask 项目下的文件
从 static 开始