old_contents: #!/usr/bin/env python
  # -*- coding: utf-8 -*-
  #
  # Copyright (C) 2015 GRNET S.A.
  #
  # This program is free software: you can redistribute it and/or modify
  # it under the terms of the GNU Affero General Public License as published
  # by the Free Software Foundation, either version 3 of the License, or
  # (at your option) any later version.
  #
  # This program is distributed in the hope that it will be useful,
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  # GNU Affero General Public License for more details.
  #
  # You should have received a copy of the GNU Affero General Public License
  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  
  from flask import Flask, jsonify
  
  from icaas.models import db
  from icaas.controllers.main import main
  from icaas.error import InvalidAPIUsage
  
  
  def create_app(object_name, env="prod"):
      """
      An flask application factory, as explained here:
      http://flask.pocoo.org/docs/patterns/appfactories/
  
      Arguments:
          object_name: the python path of the config object,
                       e.g. appname.settings.ProdConfig
  
          env: The name of the current environment, e.g. prod or dev
      """
  
      app = Flask(__name__)
  
      app.config.from_object(object_name)
      app.config['ENV'] = env
  
      # initialize SQLAlchemy
      db.init_app(app)
  
      # Override the default error handler
      @app.errorhandler(InvalidAPIUsage)
      def handle_invalid_usage(error):
          response = jsonify(error.to_dict())
          response.status_code = error.status_code
          return response
  
      # register our blueprints
      app.register_blueprint(main)
  
      return app
  
  # vim: ai ts=4 sts=4 et sw=4 ft=python
  
new_contents: #!/usr/bin/env python
  # -*- coding: utf-8 -*-
  #
  # Copyright (C) 2015 GRNET S.A.
  #
  # This program is free software: you can redistribute it and/or modify
  # it under the terms of the GNU Affero General Public License as published
  # by the Free Software Foundation, either version 3 of the License, or
  # (at your option) any later version.
  #
  # This program is distributed in the hope that it will be useful,
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  # GNU Affero General Public License for more details.
  #
  # You should have received a copy of the GNU Affero General Public License
  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  
  from flask import Flask, jsonify
  
  from icaas.models import db
  from icaas.controllers.main import main
  from icaas.error import InvalidAPIUsage
  from icaas import settings
  
  
  def create_app(object_name, env="prod"):
      """
      An flask application factory, as explained here:
      http://flask.pocoo.org/docs/patterns/appfactories/
  
      Arguments:
          object_name: the python path of the config object,
                       e.g. appname.settings.ProdConfig
  
          env: The name of the current environment, e.g. prod or dev
      """
  
      app = Flask(__name__)
  
      app.config.from_object(object_name)
      app.config['ENV'] = env
  
      # initialize SQLAlchemy
      db.init_app(app)
  
      # Override the default error handler
      @app.errorhandler(InvalidAPIUsage)
      def handle_invalid_usage(error):
          response = jsonify(error.to_dict())
          response.status_code = error.status_code
          return response
  
      # register our blueprints
      app.register_blueprint(main)
  
      # set the secret key
      app.secret_key = settings.SECRET_KEY
  
      return app
  
  # vim: ai ts=4 sts=4 et sw=4 ft=python
  
subject: Add the settings' SECRET_KEY in the Flask App