Hello,
I am using Sanic 20.9.1 and uvicorn 0.12.2 to serve small mp4 files. Sanic works perfectly but if use uvicorn like in the following code, the mp4 files are not served properly and the player is not able to decode the incoming data.
Is this a uvicorn issue?
file: main.py
from sanic import Sanic
from sanic.response import json
import uvicorn
app = Sanic("App Name")
app.static('vod.html', "vod.html", stream_large_files=1024 * 1024)
app.static('sample.mp4', "sample.mp4", stream_large_files=1024 * 1024)
@app.route("/")
async def test(request):
return json({"hello": "world"})
if __name__ == "__main__":
#app.run(host="0.0.0.0", port=8000)
uvicorn.run(app, host="0.0.0.0", port=8000, workers=1, log_level="debug")
file: requirements.txt
sanic==20.9.1
Sanic-Cors==0.10.0.post3
sanic-openapi==0.6.2
uvicorn==0.12.2
h11==0.8.0
file vod.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>VOD Test</title>
<style>
video {
width: 480px;
height: 282px;
background-color: black;
margin: 5px 10px 5px 10px;
padding: 5px;
float: left;
}
</style>
</head>
<body>
<div id="header">
<video src='http://localhost:8000/sample.mp4' autoplay controls></video>
</div>
</body>
</html>
Thanks!
Jay