У меня есть приложение фляги с кнопкой загрузки для видео (mp4), и я пытаюсь выяснить, как заставить видео воспроизводиться на экране после загрузки. В настоящее время открывается общий серый видеоэкран, но видео не воспроизводится. Я включаю части моих файлов app.py и index.html ниже. У меня также есть кнопка прогнозирования, с которой я бы хотел иметь возможность взаимодействовать, пока видео продолжает воспроизводиться.
Буду признателен за любые предложения, как этого добиться.
@app.route('/', methods=['GET'])
def index():
# Main page
return render_template('index.html')
@app.route('/predict', methods=['GET', 'POST'])
def upload():
if request.method == 'GET':
return render_template('index.html')
if request.method == 'POST':
# Get the file from post request
f = request.files['file']
# Save the file to ./uploads
basepath = os.path.dirname(__file__)
file_path = os.path.join(
basepath, 'static', secure_filename(f.filename))
f.save(file_path)
result = model_predict(file_path, model)
return jsonify(result)
return None
if __name__ == '__main__':
# app.run(port=5002, debug=True)
# Serve the app with gevent
http_server = WSGIServer(('', 5000), app)
http_server.serve_forever()
`
<div>
<h4>
<center></center>
</h4>
<br>
</br>
<center>
<form id="upload-file" method="post" enctype="multipart/form-data">
<center>
<label for="imageUpload" class="upload-label">
Upload (mp4)
</label>
</center>
<input type="file" name="file" id="imageUpload" accept=".mp4">
</form>
</center>
<div class="image-section" style="display:none;">
<div class="img-preview">
<div id="imagePreview">
<html>
<head>
</head>
<center>
<body>
<center>
<video controls width="500" style="center">
<source src="{{url_for('static', filename=f)}}" type="video/mp4" autoplay>
Sorry, your browser doesn't support embedded videos.
</video>
</center>
</body>
</html>
<input type="file" name="file[]" class="file_multi_video" accept="video/*">
</div>
</div>
<div>
<button type="button" class="btn btn-primary btn-lg " id="btn-predict">Identify</button>
</div>
</div>
<div class="loader" style="display:none;"></div>
<h3 id="result">
<span> </span>
</h3>
</div>
</center>