def create_app(config=None): app = Flask(__name__) # If no config file is passed in on the command line: if config is None: #config = os.path.join(app.root_path, os.environ.get('FLASK_APPLICATION_SETTINGS')) config = os.path.join(os.path.dirname( __file__ ), "../config/", "config.cfg") app.config.from_pyfile(config) # Secret key needed to use sessions. app.secret_key = app.config['SECRET_KEY'] app.mail = Mail(app) # Initialize SQL Alchemy and Flask-Login # Instantiate the Bcrypt extension db.init_app(app) if (app.config['CREATE_SCHEMA']): with app.app_context(): db.create_all() login_manager.init_app(app) bcrypt.init_app(app) # CSRF protection csrf.init_app(app) # Web assets (js, less) assets = Environment(app) js = Bundle('js/main.js', filters='jsmin', output='gen/bundle.js') assets.register('js_all', js) # Automatically tear down SQLAlchemy @app.teardown_request def shutdown_session(exception=None): db.session.remove() @app.before_request def before_request(): g.user = current_user app.register_blueprint(unauthenticated) app.register_blueprint(authenticated) app.register_blueprint(users) return app
def create_app(config=None): app = Flask(__name__) # If no config file is passed in on the command line: # if config is None: # config = os.path.join(app.root_path, os.environ.get('FLASK_APPLICATION_SETTINGS')) # app.config.from_pyfile(config) # Secret key needed to use sessions. app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/easytransfer.db' app.config['SECRET_KEY'] = 'gi3mHUx8hcLoQrnqP1XOkSORrjxZVkST' app.secret_key = app.config['SECRET_KEY'] # Initialize SQL Alchemy and Flask-Login # Instantiate the Bcrypt extension db.init_app(app) login_manager.init_app(app) bcrypt.init_app(app) # CSRF protection # csrf.init_app(app) # Web assets (js, less) assets = Environment(app) js = Bundle('js/main.js', filters='jsmin', output='gen/bundle.js') assets.register('js_all', js) # Automatically tear down SQLAlchemy @app.teardown_request def shutdown_session(exception=None): db.session.remove() @app.before_request def before_request(): g.user = current_user app.register_blueprint(unauthenticated) app.register_blueprint(authenticated) app.register_blueprint(users) return app
def create_app(config=None): app = Flask(__name__) # If no config file is passed in on the command line: if config is None: config = os.path.join(app.root_path, os.environ.get('FLASK_APPLICATION_SETTINGS')) app.config.from_pyfile(config) # Secret key needed to use sessions. app.secret_key = app.config['SECRET_KEY'] # Initialize SQL Alchemy and Flask-Login # Instantiate the Bcrypt extension db.init_app(app) login_manager.init_app(app) bcrypt.init_app(app) # CSRF protection csrf.init_app(app) # Web assets (js, less) assets = Environment(app) js = Bundle('js/main.js', filters='jsmin', output='gen/bundle.js') assets.register('js_all', js) # Automatically tear down SQLAlchemy @app.teardown_request def shutdown_session(exception=None): db.session.remove() @app.before_request def before_request(): g.user = current_user app.register_blueprint(unauthenticated) app.register_blueprint(authenticated) app.register_blueprint(users) return app
def create_app(config=None): app = Flask(__name__) # If no config file is passed in on the command line: if config is None: config = os.path.join(app.root_path, os.environ.get("FLASK_APPLICATION_SETTINGS")) app.config.from_pyfile(config) # Secret key needed to use sessions. app.secret_key = app.config["SECRET_KEY"] # Initialize SQL Alchemy and Flask-Login # Instantiate the Bcrypt extension db.init_app(app) login_manager.init_app(app) bcrypt.init_app(app) # CSRF protection csrf.init_app(app) # Web assets (js, less) assets = Environment(app) js = Bundle("js/main.js", filters="jsmin", output="gen/bundle.js") assets.register("js_all", js) # Automatically tear down SQLAlchemy @app.teardown_request def shutdown_session(exception=None): db.session.remove() @app.before_request def before_request(): g.user = current_user app.register_blueprint(unauthenticated) app.register_blueprint(authenticated) app.register_blueprint(users) # app.register_blueprint(upload) return app
def create_app(config=None): app = Flask(__name__) # If no config file is passed in on the command line: if config is None: config = os.path.join(app.root_path, os.environ.get('FLASK_APPLICATION_SETTINGS')) app.config.from_pyfile(config) # Secret key needed to use sessions. app.secret_key = app.config['SECRET_KEY'] # Initialize SQL Alchemy and Flask-Login # Instantiate the Bcrypt extension db.init_app(app) login_manager.init_app(app) bcrypt.init_app(app) # Automatically tear down SQLAlchemy @app.teardown_request def shutdown_session(exception=None): db.session.remove() @app.before_request def before_request(): g.user = current_user # URLs app.add_url_rule('/', 'index', index) app.add_url_rule('/login/', 'login', login_view, methods=['GET', 'POST']) app.add_url_rule('/home/', 'home', home) app.add_url_rule('/users/create/', 'user_create', user_create, methods=['GET', 'POST']) app.add_url_rule('/logout/', 'logout', logout_view) return app