title: Package and Module in Python for creating a Web App using Flask
body: <p>Currently, I am in process of coding a web interface for a company.</p>
  
  <p>This web interface is based on python micro-framework Flask. I want to use MVC principle to build this interface. And I have some questions in mind.</p>
  
  <p>The model will contain the data for ORM-mapping with help of SQLAlchemy, no problem there.<br>The views is based on some html and css, I don't think there will be a problem here either.</p>
  
  <p>The controller on the other hand is kind of cumbersome.<br>
  I want to separate the pages into module and the script application into separate modules, and packed all these modules into a packages of controller for example like:</p>
  
  <ul>
  <li>Session Module (Login/Logout/Cookies)</li>
  <li>Administrator Module (Manage Registered Accounts/Content/etc.)</li>
  <li>Application Script 1 Module</li>
  <li>Application Script 2 Module</li>
  <li>Application Script 3 Module</li>
  </ul>
  
  <p>I understand that to render the template you need to use the routing etc. But how do I make it that if a certain link is called, it will called the specific module and pull methods from there. Is it OK, to create a one main controller for the routing and for every method in the routing I import one of the modules above?</p>
  
  <pre><code>@app.route('/')
    def index():
      return render_template("index.html")
  
  @app.route('/login/', methods = ('GET', 'POST'))
    def login():
      from session import login
      -&gt; call method from 'login' here
  
  @app.route('/account/&lt;username&gt;', methods = ('GET', 'POST'))
    def login():
      from administrator import view_account
      -&gt; call method from 'view_account' here
  </code></pre>
  
  <p>is this a good practice?
  or should I just start at the header and import every module I have in this package.
  My first thinking was to prevent that the apps to load to long because of the size of the script, only certain module will be called if the page that need that module is accessed or something like that.</p>