锦中融合门户系统

我们提供融合门户系统招投标所需全套资料,包括融合系统介绍PPT、融合门户系统产品解决方案、
融合门户系统产品技术参数,以及对应的标书参考文件,详请联系客服。

利用Python实现服务大厅门户中的视频功能

2025-02-13 23:08
融合门户在线试用
融合门户
在线试用
融合门户解决方案
融合门户
解决方案下载
融合门户源码
融合门户
详细介绍
融合门户报价
融合门户
产品报价

<?python

# 导入必要的库

from flask import Flask, render_template, request, redirect, url_for

from werkzeug.utils import secure_filename

import os

# 初始化Flask应用

app = Flask(__name__)

# 配置文件上传目录

迎新工作管理系统

UPLOAD_FOLDER = 'uploads'

app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

# 允许的文件扩展名

ALLOWED_EXTENSIONS = {'mp4', 'avi', 'mov'}

def allowed_file(filename):

return '.' in filename and \

filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS

@app.route('/')

def index():

return render_template('index.html')

@app.route('/upload', methods=['GET', 'POST'])

def upload_file():

if request.method == 'POST':

# 检查是否有文件在post请求中

if 'file' not in request.files:

return redirect(request.url)

file = request.files['file']

# 如果用户没有选择文件,浏览器也会提交空文件名到服务器

if file.filename == '':

return redirect(request.url)

if file and allowed_file(file.filename):

filename = secure_filename(file.filename)

file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))

return redirect(url_for('uploaded_file', filename=filename))

return '''

Upload Video

Upload new File

融合门户

'''

@app.route('/uploads/')

def uploaded_file(filename):

return render_template('video.html', filename=filename)

if __name__ == '__main__':

app.run(debug=True)

?>

<!DOCTYPE html>

<html>

<head></head>

<body>

<video width="320" height="240" controls>

<source src="/uploads/{{ filename }}" type="video/mp4">

Your browser does not support the video tag.

</video>

</body>

服务大厅

</html>

本站部分内容及素材来源于互联网,由AI智能生成,如有侵权或言论不当,联系必删!