os 如何获取路径
在项目中如果想要获取绝对路径的话
要使用 os.getcwd() 在线上项目用这种方法比较多
@ac.route('/v1/getspecs/xdla', methods=['GET']) def download_xdla(): name = request.args.get('name') phone = request.args.get('phone') if Users.query.filter(Users.name == name).first() and Users.query.filter(Users.phone == phone).first(): file_path = os.getcwd() + '/xd_project/static/说明书.docx' return send_file(file_path, as_attachment=True, ) else: return '收集用户信息失败'
浙公网安备 33010602011771号