Hi,
Based on the information provided, most likely the issue lies with the file path or the permission/access to the file is insufficient. Kindly make sure that the file is present when it is trying to rename the file when midnight comes.
Try replacing it with the following code:
handler = TimedRotatingFileHandler('flask_server.log', when="midnight", interval=1)
It should create a file called flask_server.log in the root directory and rename it once midnight. Also, remember to provide the sufficient permission to rename the file when running the program.