INNER CODE UNIT · Python
upload_sample_video
chonyy/AI-basketball-analysis · app.py:85
def upload_sample_video():
global shooting_result
shooting_result['attempts'] = 0
shooting_result['made'] = 0
shooting_result['miss'] = 0
if (os.path.exists("./static/detections/trajectory_fitting.jpg")):
os.remove("./static/detections/trajectory_fitting.jpg")
if request.method == 'POST':
f = request.files['video']
# create a secure filename
filename = secure_filename(f.filename)
print("filename", filename)
# save file to /static/uploads
filepath = os.path.join(app.config['UPLOAD_FOLDER'], filename)
print("filepath", filepath)
f.save(filepath)
session['video_path'] = filepath
return render_template("shooting_analysis.html")