title: How can I make command line arguments visible to Flask routes?
body: <p>I am using Flask to build a tool to view data locally in a browser. I want to pass the directory containing the data as a command line argument, and then pass it to the appropriate routing function to do the rendering.</p>
  
  <p>This does what I want, but with global variables:</p>
  
  <pre><code>dataDir = None
  
  def initializeData(pathname):
      global dataDir
      dataDir = pathname
  
  @app.route('/')
  def home():
      # Use dataDir as desired
  
  if __name__ == '__main__':
      initializeData(sys.argv[1])
      app = Flask(__name__)
      app.run()
  </code></pre>
  
  <p>Is there a better way to communicate between the command line and my routes?</p>