You are running your WSGI app with the Flask test server, which by
default uses a single thread to handle requests. So when your one request
thread tries to call back into the same server, it is still busy
trying to handle that one request.
You'll need to enable threading:
if __name__ == "__main__":
or use a more advanced WSGI server; see Deployment Options.