This is my usual static serving lines of code.
app.static("/static/videos/", "./static/videos/", use_content_range=True)
app.static("/static/documents/", "./static/documents/")
app.static("/static/images/", "./static/images/")
This works perfectly fine on my Ubuntu, but today I tried the same code on my windows machine and it’s not working.
All the files are exactly in the same directories, in the same hierarchy, with no changes to code.
As a workaround to server those files, I am doing this
img_file_names = tuple(*[files for (_, _, files) in os.walk('./static/images/')])
@app.get("/static/images/<img_file_name:path>")
async def serve_img(_, img_file_name):
if img_file_name in img_file_names:
return await file('./static/images/' + img_file_name)
return empty()
I am doing the same for videos and document files
The above code works perfectly fine both on Ubuntu and windows but the first static config is much more convenient.
What’s the reason it’s not working? Thanks in advance