title: Can I use external methods as route decorators in Python/Flask?
body: <p>My main app file is currently a series of method definitions, each attached to a route. I've got 3 distinct parts to my app (main, admin, api). I'm trying to split out methods into external files for better maintenance but I like Flask's simplicity in using route decorators for my application's URLs.</p>
  
  <p>One of my routes currently looks like this:</p>
  
  <pre><code># index.py
  @application.route('/api/galleries')
  def get_galleries():
      galleries = {
          "galleries": # get gallery objects here
      }
      return json.dumps(galleries)
  </code></pre>
  
  <p>But I'd like to extract the get_galleries method into a file containing methods for my API:</p>
  
  <pre><code>import api
  @application.route('/api/galleries')
  api.get_galleries():
  </code></pre>
  
  <p>The problem is that when I do that I get an error. Is this possible, and if so how do I do it?</p>