title: Javascript accessing local JSON files in flask app
body: <p>I'm running a flask app locally and my goal is to pass a dictionary from python to Javascript. I currently am able to store the dictionary as a json file in the local folder, however my ajax request cannot seem to access the local json. Why would this not work, and is there a flask module that allows me to pass python dictionaries to javascript locally?</p>
  
  <pre><code># app.py
  dictionary_a = {
      "a": {
          "b": {
              "function_handler": c,
              "defaults": {'d':e, 'f':g},
          },
          "h": {
              "function_handler": i,
              "defaults": {'d':l},
          },
      },
  }
  
  def dumper(obj):
      try:
          return obj.toJSON()
      except:
          return obj.__dict__
  
  
  @app.route('/')
  def index():
      jsonn = json.dumps(dictionary_a, default=dumper, indent=2)
      with open('data.json', 'w') as json_file:
          json.dump(jsonn, json_file)
      return render_template('home.html')
  </code></pre>
  
  <p>This is my python code,</p>
  
  <pre><code># code.js
  $.getJSON("../../data.json", function(json) {
      console.log(json); // this will show the info it in firebug console
  });
  </code></pre>
  
  <p>This is code in javascript</p>
  
  <p>Folder structure is</p>
  
  <pre><code>&gt;project
    -app.py
    &gt;static
      &gt;js
        -code.js
    -data.json
  </code></pre>
  
  <p>error message: GET <a href="http://localhost:5000/data.json" rel="nofollow noreferrer">http://localhost:5000/data.json</a> 404 (NOT FOUND)</p>