bin.html
<div>
{% if context.pic %}
{% for li in context.pic %}
<div style="float:left;width:22.5%;">
{% load static %}
<div class="box" >
<video muted width="400" height="270" controls preload="none">
<source src="/static/{{li}}" type="video/mp4">
</video>
</div>
<div class="box" >
<p>
名前:{{context.person.0}}
<br>
年目:{{context.person.1}}
<br>
メール:{{li}}
<br>
</p>
</div>
</div>
{% empty %}
<li>no!</li>
{% endfor %}
{% endif %}
</div>
views.py
def bing(request):
template=loader.get_template("bin.html")
pic_root="你的视频目录,setting配置需要修改一致。"
root = os.listdir(pic_root)
list_root=[]
for r in root:
list_root.append(r)
context={"title":"日本語の世界に入ってくだい!","time":datetime.datetime.now(),"person":["Tory",21,"東京"],"pic":list_root,"num":len(list_root)}
request_context = RequestContext(request, context)
request_context.push(locals())
html=template.render(context=locals(), request=request)
return HttpResponse(html)
setting.py
Vedio_DIR="你的视频目录"
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(Vedio_DIR)
]
错误(虽有错误,运行正常,错误异常处理即可)
File "C:\Python27\lib\socket.py", line 307, in flush
self._sock.sendall(buffer(data, write_offset, buffer_size))
error: [Errno 10053]#您的主机中止了一个已建立的连接。
解决(A,B同时建立连接,其中一个被终止。A或B被终止后不断尝试重连,不断循环)
C:\Python27\lib\socket.py
def flush(self):
....
....
while write_offset < data_size:
self._sock.sendall(view[write_offset:write_offset+buffer_size])
write_offset += buffer_size
....
....
改为=>
def flush(self):
....
....
while write_offset < data_size:
try:
self._sock.sendall(view[write_offset:write_offset+buffer_size])
write_offset += buffer_size
except Exception as e:
pass
存在问题
局域网内手机连接后,无法访问视频,下载中也无法观看(电脑端正常)。若哪位大神看到,求告知!
其他问题解决方案