Conversation
| .PHONY: init | ||
| init: | ||
| python3 -m virtualenv .venv | ||
| python3 -m venv .venv |
There was a problem hiding this comment.
Thought [non-blocking]:
Is it trivial to consider uv here?
There was a problem hiding this comment.
I'll likely take a look at the build/packaging process at some point in the future, but not now, this approach is definitely more messy to use
| ) | ||
|
|
||
| filename = os.path.basename(file_path) | ||
| response['Content-Disposition'] = f'inline; filename="{filename}"' |
There was a problem hiding this comment.
Thought [non-blocking]:
Thinking about headers here. As we know this is static content, are there any headers we could add to help with upstream caching? Or is this not this layers responsibility?
There was a problem hiding this comment.
Went for least surprise here, since the static filenames aren't hashed in any way (as far as I know) any implementation with caching could cause weirdness. If caching of these files is desired then not using this package and deploying as per Django recommendations on a CDN seems the approach to follow.
| async def middleware(request): | ||
| if files.get(request.path): | ||
| return FileResponse(open(files[request.path], 'rb')) | ||
| file_path = files[request.path] |
There was a problem hiding this comment.
Not for now but ASGI has two relevant extensions which work a bit like X-SEND-FILE. One allows you to hand over a fd and the server will get the os to write the data, without python getting involved (Zero Copy Send). Even better you can return a path and have the server stream it for you (Path Send). These are both likely to be much faster.
There was a problem hiding this comment.
Ah, good to know, will have to have a look at some point, although not looking to complicate this library too much given it's target usage.
No description provided.