项目结构
templates\index.html
main.py
网页
templates\index.html
<!DOCTYPE html>
<html>
<head>
<title>视频播放</title>
</head>
<body>
<h1>视频播放</h1>
<video width="320" height="240" controls>
<source src="/video/处处吻.mp4" type="video/mp4">
你的浏览器不支持 HTML5 video 标签。
</video>
</body>
</html>
python文件
main.py
from flask import Flask, render_template, send_from_directory
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html') # 你的视频播放页面
@app.route('/video/<filename>')
def video(filename):
VIDEO_PATH = 'E:/code/flask/video'
# filename='1.mp4'
return send_from_directory(directory=VIDEO_PATH, path=filename)
if __name__ == '__main__':
app.run(debug=True)
–
–
–
发表回复