I have a html file which references static object like this
>
You should remove "/" before "/static" in your code:
send_from_directory('/static', filename)
change it to:
send_from_directory('static', filename)
However, in some environments, the server itself does not let running this command on the static folder/directory. Because it is set to be a static file server. For example, with the google cloud, you should build a directory called tmp beside the static folder and then do the send_from_directory command with the tmp folder:
return(send_from_directory('tmp', filename))