I’m using send_from_directory function in flask. The code below perfectly works if I use absolute path to the local file but when it is deployed it returns 404.
link in HTML to download the file: <a href="{{ url_for('users.download_pdf', session_token=user.session_token, filename=po) }}" target="_blank">{{ po }}</a>
There will always be differences between environments: development mode/Local, production mode/Render, OS, versions, resources, etc. These differences need to be considered and configured as required for your own app in each environment.
Render instances have an ephemeral filesystem, meaning any file written to the instance after it has booted will be lost when it next restarts (e.g. spun down if on free instance type, next deploy, manual restart, etc.).
If the files in question are generated/saved to the instance, they’ll be lost on each deploy, so you would need to save them to a persistent store, e.g., a Render Disk (which is chargeable and also requires a paid instance type) or an external service like AWS S3.