python - 烧瓶发送大视频文件不起作用
问题描述
我想制作一个视频共享网站(如 youtube),但在发送大型视频文件时遇到问题。当我尝试访问我的网站并加载视频时,我的网站开始发送文件,但 Firefox 在一段时间后停止接收数据。我知道一些网站将大视频分成几部分并单独发送每个部分,但我不知道如何用烧瓶做到这一点。
到目前为止,这是我的代码:
import flask
from mimetypes import guess_type
app = flask.Flask(__name__)
def rf(path, mode='rb'):
file = open(path, mode)
data = file.read()
file.close()
return data
@app.route('/')
def index():
return flask.Response(rf('./root/index.html'))
@app.route('/favicon.ico')
def favicon():
return flask.Response(rf('./root/favicon.png'))
@app.route('/<path:pth>')
def autopath(pth):
if not isfile('./root/' + pth):
pth += '.html'
if not isfile('./root/' + pth):
return flask.Response("ERR: 404", status=404)
mime = guess_type(pth, False)
if mime[0] == None:
mime = ('text/text')
return flask.Response(rf('./root/' + pth), mimetype=mime[0])
if __name__ == '__main__':
app.run('localhost', 80)
烧瓶中是否有允许分块发送大文件的功能?
解决方案
推荐阅读
- sql - SQL查询在同一表列中具有多个关键字的搜索操作
- javascript - 将 JavaScript 字符串从网页传递到 C# Winforms?
- ios - 将 UITextField MM/YY 格式化为过期
- python - 使用命令行的python脚本中的AttributeError
- docker - Kubernetes部署数据库连接错误
- asp.net - 不支持文化。参数名称:name zh-hans-cn 是无效的文化标识符
- node.js - 使用 multer 快速上传文件
- c# - Web 套接字,斑点,将消息从客户端发送到服务器
- angularjs - _co.userData 是未定义的离子 3
- javascript - 联系表格问题?