Step A1
The folder answers
Every file in the folder is alive at its own address, before any name is minted for it.
A folder, filepages/, deployed with the application. At the
very end of the serving pathway — after the datastore has been asked, after
the old names have been checked for redirects, just before the 404 — the
folder gets to answer. A file at filepages/sample/hello.html is
served at /sample/hello.html; its stylesheet beside it is served
beside it. Because the address space mirrors the folder, relative references
between companions work exactly as they do on disk.
Two things make this the right first step. It is end-to-end immediately:
drop a file, request it, see it. And the point of attachment is the least
invasive one in the whole program — the fall-through position means every
request that could be answered before the graft is still answered the same
way after it. Note also whose organ does the work: Flask's
send_from_directory already guards path traversal and already
speaks ETag and Last-Modified — the graft inherits step seventeen's virtue
without writing a line of caching code.
# main.py, at the end of the not-found branch of view_page:
# after entities, after redirects, before the 404 --
# the folder gets to answer.
try:
return send_from_directory(FILEPAGES, path, max_age=300)
except Exception:
abort(404)
The graft attaches where nothing existing can feel it.