How would I only allow users authenticated via Python code to access certain files on the server?
For instance, say I have /static/book.txt which I want to protect. When a user accesses /some/path/that/validates/him, a Python script deems him worthy of accessing /static/book.txt and redirects him to that path.
How would I stop users who bypass the script and directly access /static/book.txt?
You might want to just have your Python script open the file and dump the contents as its output if the user is properly authenticated.  Put the files you want to protect in a folder that is outside of the webserver root.
Protecting online static content