title: Python Flask persistent object between requests
body: <p>I am creating a web interface for OMXPlayer on the Raspberry Pi.  I'm trying to create a more REST like API for controlling the video while its playing.  The issue I'm having is how to control the video while it is playing.</p>
  
  <p>Currently I can create a Player object which as some methods available to start and stop the video.</p>
  
  <pre><code>@main.route("/video", methods=["GET", "POST"])
  @login_required
  def video():
      form = VideoForm()
  
      if form.validate_on_submit():
          url = form.url.data
          vid_output = form.vid_output.data
          player = Player(url=url, output=vid_output)
          player.toggle_pause()
          return redirect('/video')
  
      return render_template("video.html", form=form)
  </code></pre>
  
  <p>Now I want to have another URL that can run the Player.toggle_pause() method again.  </p>
  
  <pre><code>@main.route("/video/stop", methods=["GET", "POST"])
  @login_required
  def video_stop():
      player.toggle_pause()
  </code></pre>
  
  <p>My problem is that I cannot find a way to have this object persist between the two requests.  The video will start playing after sending the first request, but trying to stop or control it will not allow me to access the created object.  Is there a way to persist this object between two seperate requests?</p>