title: Flask Multithreading with Python
body: <p>I am just wondering is it possible to start two functions to work in same time with Flask server? I need to start <code>function_1</code> after it trigger <code>function_2</code> and run both functions in same time. Is it possible?</p>
  
  <pre><code>def function_1():
      yield "start_function_2"
      counter = 0
      while True:
         counter += 1
         print counter
  
  
  def function_2():
      second_counter = 0
      while True:
         second_counter += 1
         print second_counter
  
  def main():
      return render_template("index.html")
  
  @app.route("/start_functions", methods=["POST"])
  def start_functions():
      data = request.data
      if request.method == "POST":
          for i in function_1(data):
             if (i == "start_function_2"):
                function_2()
  
  if __name__ == "__main__":
      app.run(dhost="0.0.0.0", port=port)
  </code></pre>