Spaces:
Runtime error
Runtime error
File size: 568 Bytes
f552622 f2104b8 6a9cdb5 f552622 f2104b8 f552622 6a9cdb5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import os
from flask import Blueprint, request, jsonify
from models import Video
from database import db
upload_bp = Blueprint("upload", __name__)
UPLOAD_FOLDER = "uploads"
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
@upload_bp.route("/", methods=["POST"])
def upload():
file = request.files["file"]
title = request.form.get("title")
path = os.path.join(UPLOAD_FOLDER, file.filename)
file.save(path)
video = Video(title=title, filename=file.filename)
db.session.add(video)
db.session.commit()
return jsonify({"message": "uploaded"}) |