I'm not sure, but I think this may be a problem with werkzeug. I have several flask projects and I found that all works well with werkzeug 2.2.2 but when I upgraded to 3.1 I get this error.
I ended up setting FLASK DEBUG to 0. This allowed me to use the pycharm debugger. I do not get the error showing in the browser (but I can see them in the console anyway). The other downside is it stops the auto reloader so I need to re-start between code changes.