title: Flask Server not responding to HTTP POST Request
body: <p>I built a simple flask server in order to automate python scripts based on an HTTP POST Request coming in from an outside service. This service sends these requests in response to events that we have created based on data conditions. All the flask server needs to do is parse the requests, and take the numerical value stored in the request and use it to run the corresponding python script. At one point, this system was working consistently. Fast forward a few months, the server was no longer working when tried again. No changes were made to the code. According to wireshark, The computer hosting the flask server is receiving the request to the correct port, but the request is now timing out. The host system is failing to respond to the request. Any Idea what is going on here? The firewall has temporarily been turned off.</p>
  <p>Alternatively, is there another better package to achieve this goal with?</p>
  <pre><code>from flask import Flask, request
  import threading
  import runpy
  
  app = Flask(__name__)
  
  
  @app.route('/', methods=['POST'])
  def PostHandler():
      directory = {}
      with open(r&quot;M:\redacted&quot;) as f:
          for line in f:
              (key,val) = line.split()
              directory[int(key)] = val
      print(directory)
      path = r&quot;M:\redacted&quot;
     
  
      
      content = request.json
      content = content['value']
      print(content)
      sel_script = int(content)
      
      print(directory[sel_script])
     
      runpy.run_path(path_name=path + directory[sel_script])
  
      return
  
  
  app.run(host=&quot;10.244.xx.xx&quot;, port=8080, threaded=True)
  
  </code></pre>
  <p><a href="https://i.stack.imgur.com/gr2Qw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gr2Qw.png" alt="This is the POST request I am sending via Postman. Which of the settings matter? I have the firewall turned off." /></a></p>