Avatar upload + dedicated endpoint for serving binary images from database #62
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Honestly, Claude + Cursor did this in just 3 prompts. I'm going to have to study it to make sure I understand fully how it works. Basically, we have:
My own instinct was to provide the base64-encoded image as a context variable to the Jinja2 template rather than use a dedicated image endpoint, but Claude convinced me that was a bad idea because binary encoding is more efficient, and we should use a dedicated image endpoint instead. (The nested use of GET endpoints is intriguing; I may have to explore how to take advantage of this in other contexts.)
Honestly I think we should eliminate the URL option altogether, which should let us simplify the HTML, Javascript, and Pydantic/database models a bit. And we should probably do a little more robustness testing to see what happens with different file sizes, dimensions, image types, etc. But this is a pretty great start.
(When testing with changed database models, remember to set
set_up_db(drop = True)
in main.py.)