title: Grafana JSON API: How to make a proper /query endpoint?
body: <p>I'm making the JSON API <a href="https://marcus.se.net/grafana-json-datasource/" rel="nofollow noreferrer">with this plugin</a> for Grafana. I return the json_data which contains timestamp. Based on this data I make a timeseries with bars graph style. However I return all items from my database.</p>
  <p>Instead of that, I would like to return my data, based on time range.</p>
  <p>I tried to get the requested json, which should contain the current time range for visualization with <code>request.get_json()</code>. Something like that:</p>
  <p><a href="https://i.stack.imgur.com/hoQA9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hoQA9.png" alt="enter image description here" /></a></p>
  <p>My <code>/query</code> returns the actual query result (timeseries set of data) and should receive the json:</p>
  <pre><code>@app.route('/query', methods=['POST', 'GET'])
  def query():
  
      req = request.get_json()
      range = req['request']['range']
      
      json_data = get_from_database(range)
  
      return json_data
  </code></pre>
  <p>However, after I added the request, I got this error: <code>Failed to decode JSON object: Expecting value: line 1 column 1 (char 0)</code>.</p>