我试图将视频保存到本地文件夹,但不起作用。
这是我的代码:
导入一些库:
import flask
from flask import render_template, request, redirect, send_from_directory
from werkzeug.utils import secure_filename
主要代码:
app = flask.Flask(__name__)
app.config['DEBUG'] = True
app.config["VIDEO_UPLOADS"] = "./input/"
APP_ROOT = os.path.dirname(os.path.abspath(__file__))
@app.route('/video_processed', methods=['POST'])
def video_processed():
if request.method == "POST":
file = request.files['file']
file.save(os.path.join(APP_ROOT,'/static/video/', secure_filename(file.filename)))
return True
app.run()
然后我用curl
进行测试:
curl -X POST -F file=@"/home/data/input/IMG_6966.MOV" http:/127.0.0.1:5000/video_processed
然后我得到这个错误:
FileNotFoundError: [Errno 2] No such file or directory: '/static/video/IMG_6966.MOV'
我的代码有什么问题吗?