code: def stop(host=None, port=None):
      
      app.config['HOST'] = first_value(host, app.config.get('HOST',None), '0.0.0.0')
      app.config['PORT'] = int(first_value(port, app.config.get('PORT',None), 5001))
      if app.config['HOST'] == "0.0.0.0": 
          host="127.0.0.1"
      else:
          host = app.config['HOST']
      port = app.config['PORT']    
      try:
          if requests.get('http://%s:%s/api/status' % (host, port)).status_code == 200:
              requests.get('http://%s:%s/api/stop' % (host,port))
              print('web server is stopped', file=sys.stdinfo)
          else:
              print('web server is not flaskserver', file=sys.stderr)
      except:
          print('web server is not flaskserver or not start', file=sys.stderr)
docs: stop of web server