title: Django app running fine on localhost, but not working on elastic beanstalk 500 internal errors
body: <p>I have a django app, and it works fine on localhost (no problems). It loads a json file into a data structure (Trie), and is being used in a single route. It takes about 2-3 seconds for the file to be read, and build the Trie (there are thousands of words in my list). All of this is fine localhost as it only takes 2-3 seconds a single time (when you start the server). Then when you call a route on the front end with a POST to the route it performs the search on the Trie and returns the results (OK). Everything works fine localhost. However whenever I try this same exact approach on AWS Elastic Beanstalk, it returns 500 Internal Server Error on every route (routes that don't use this Trie are also throwing this exact same error code). So I am going to show some relevant code as to how I load the file, and how it is used in the app.</p>
  <pre><code>module_dir = os.path.dirname(__file__)
  file_path = os.path.join(module_dir, 'trie.json')
  myTrie = Trie()
  myTrie.load(file_path)#Loads the trie from a json file that is just a list(array)
  ...
  ...
  #in search view post route
  return Response(myTrie.search(word)) #note word is part of the request body.
  </code></pre>
  <p>This all works perfectly fine localhost, and it finds and loads the file into the Trie perfectly, however this exact same code causes all routes (not just the search routes, or user routes etc) to return a 500 Internal Error (not 502 bad gateway), the entire app is unusable when this gets deployed to the app... Oddly enough if I don't call MyTrie.load(file_path) the app remains up and all routes work (however the trie has no data to search making the route useless).</p>
  <p>Here is part of the structure my app uses:
  <br></p>
  <blockquote>
  <p>MyAPP:<br></p>
  <blockquote>
  <p>MyAppEnv<br>
  MyApp<br></p>
  <blockquote>
  <p>trie.py<br></p>
  </blockquote>
  </blockquote>
  </blockquote>
  <blockquote>
  <blockquote>
  <p>manage.py<br>
  users<br>
  requirements.txt<br>
  Procfile<br>
  ...<br>
  search<br></p>
  <blockquote>
  <p>views.py<br>
  trie.json<br></p>
  </blockquote>
  </blockquote>
  </blockquote>
  <p>Another thing I would like to mention is that for it to work localhost I need to import Trie in manage.py like from MyApp.trie import Trie. However it 100% works localhost no problems.<br>I'm thinking this is a problem with reading the file when it is uploaded to elastic beanstalk, but I'm not sure. If it were a problem with loading the file, then why does it deploy as OK, but every route gives a 500 internal server error (except the &quot;/&quot; route). <br> How would I go about debugging this problem to see what the issue is, and what exactly is the issue? Thanks</p>