title: Share global variables between two @app.route
body: <p>I am going to set some data in a global variable once "<strong>/setvalue</strong>" route is called.</p>
  
  <p>Then whoever wants to retrieve this data(even from outside of the web app, browser) can access it.</p>
  
  <p>The problem is the call for retrieving the data comes from outside, e.g. a client who hits the URL from any browser can get this data</p>
  
  <p>I have tried using "<strong>g</strong>" as follow, but it is not working:</p>
  
  <pre><code>from flask import g
  
  @app.route("/setvalue", methods = ['POST'])
  def setvalue():  
      content = request.get_json()
      g.content = content
      return format(content) #"set"
  
  
  @app.route("/getvalue" )
  def getvalue():      
      return g.content 
  
  
  from flask import Flask, jsonify, request
  from flask import g
  </code></pre>
  
  <p>As the above code show, I will call "<strong>/setvalue</strong>" to initiate the web app.</p>
  
  <p>And whoever calls "<strong>/getvalue</strong>" will get the value that was initiated.</p>
  
  <p>But g.content doesn't seem to work this way. I received a 500 error. </p>
  
  <p>What is missing from my code? Thanks in advance. Your help would be greatly appreciated</p>