Reading from file and initialising variable in Phoenix on server startup

Viewed 893

I have a large file with words that I want to read into a list on server startup. The list should then be available in a controller.

I figured the file reading should take place in lib/Appname.ex

  • Where should the text file with words be placed? If I put it in web/static/assets how do I get the relative path to that location?
  • Is it a viable approach to read the list into a module Attribute in the Appname.ex (in /lib)? Or is there a better way to do it?
1 Answers
Related