def create_app(configfile=None): app = Flask(__name__) AppConfig(app, configfile) # Flask-Appconfig is not necessary, but # highly recommend =) # https://github.com/mbr/flask-appconfig Material(app) # in a real app, these should be configured through Flask-Appconfig app.config['SECRET_KEY'] = 'devkey' app.config['RECAPTCHA_PUBLIC_KEY'] = \ '6Lfol9cSAAAAADAkodaYl9wvQCwBMr3qGR_PPHcw' @app.route('/', methods=('GET', 'POST')) def index(): form = ExampleForm() form.validate_on_submit() # to get error messages to the browser flash('critical message', 'critical') flash('error message', 'error') flash('warning message', 'warning') flash('info message', 'info') flash('debug message', 'debug') flash('different message', 'different') flash('uncategorized message') return render_template('index.html', form=form) return app
def create_app(args): app = Flask(__name__) Material(app) app.config['args'] = args app.config['UPLOAD_FOLDER'] = settings.UPLOAD_FOLDER print('Passed item: ', app.config['args']) return app
def create_app(config_name): app = Flask(__name__) Material(app) app.config.from_object(config_options[config_name]) from .main import main as main_blueprint app.register_blueprint(main_blueprint) from .auth import auth as auth_blueprint app.register_blueprint(auth_blueprint, url_prefix='/authenticate') app.wsgi_app = SassMiddleware( app.wsgi_app, {'app': ('static/sass', 'static/css', '/static/css')}) db.init_app(app) login_manager.init_app(app) return app
def create_app(config_class=Config): # Define the application object flask_app = Flask(__name__) # Init the materialize framework MIGHT CHANGE AFTER Material(flask_app) # Configurations taken from function argument flask_app.config.from_object(config_class) # Initialize the various models with the flask_app db.init_app(flask_app) migrate.init_app(flask_app, db) # Create a LoginManager instance login_manager.init_app(flask_app) login_manager.login_view = 'auth.login' login_manager.login_message = '' # Sample HTTP error handling @flask_app.errorhandler(404) def not_found(error): return render_template("404.html"), 404 # Setup the DASH apps from application.pydashboard.layout import layout as layout from application.pydashboard.callbacks import register_callbacks as register_callbacks register_dashapp(flask_app, 'Dashapp 1', 'dashboard', layout, register_callbacks) # Import a module / component using its blueprint handler variable (mod_auth) #from application.mod_auth.controllers import mod_auth as auth_module from application.home import home as home_module from application.auth import auth as auth_module from application.dash import dash as dash_module # Register blueprint(s) - connects each module to the main flask application # app.register_blueprint(xyz_module) flask_app.register_blueprint(auth_module) flask_app.register_blueprint(home_module) flask_app.register_blueprint(dash_module) return flask_app
os.chdir(self.savedPath) from flask_bcrypt import Bcrypt # from token import generate_confirmation_token, confirm_token # from email import send_email from flask_mail import Mail, Message from itsdangerous import URLSafeTimedSerializer from flaskext.mysql import MySQL from logger import Logger import crawler.config as config app = Flask(__name__) Material(app) app.config['SECRET_KEY'] = 'USE-YOUR-OWN-SECRET-KEY-DAMNIT' app.config['SECURITY_PASSWORD_SALT'] = 'SALT' app.config['RECAPTCHA_PUBLIC_KEY'] = 'TEST' # app.config['MAIL_DEFAULT_SENDER'] = 'sender' app.config["MONGO_URI"] = config.MONGO_URI app.config['MAIL_SERVER'] = config.MAIL_CONFIG['server'] app.config['MAIL_PORT'] = config.MAIL_CONFIG['port'] app.config['MAIL_USE_SSL'] = True app.config['MAIL_USERNAME'] = config.MAIL_CONFIG['username'] app.config['MAIL_PASSWORD'] = config.MAIL_CONFIG['password'] app.config['MAIL_DEFAULT_SENDER'] = config.MAIL_CONFIG['def_sender'] app.config['MYSQL_DATABASE_HOST'] = config.MYSQL_CONFIG['host']
from flask import Flask from flask_login import LoginManager from flask_mail import Mail from flask_materialize import Material from flask_migrate import Migrate from flask_sqlalchemy import SQLAlchemy from config import Config # Initiate components db = SQLAlchemy() migrate = Migrate() material = Material() login = LoginManager() login.login_view = "auth.login" login.login_message = "Please log in to access this page." mail = Mail() def create_app(): """Function for creating application instance""" # Initiate app app = Flask(__name__) app.config.from_object(Config) # Setting up components for app db.init_app(app) migrate.init_app(app, db) material.init_app(app)
def test_can_initialize_app_and_extesion(): from flask import Flask from flask_materialize import Material app = Flask(__name__) Material(app)
from flask import Flask, current_app from config import Config from flask_sqlalchemy import SQLAlchemy from flask_mail import Mail from flask_materialize import Material from flask_migrate import Migrate from flaskext.markdown import Markdown from flask_wtf import import logging from logging.handlers import SMTPHandler db = SQLAlchemy() mail = Mail() materialize = Material() migrate = Migrate() markdown = Markdown() def create_app(): app = Flask(__name__) app.config.from_object(Config) db.init_app(app) mail.init_app(app)²² materialize.init_app(app) migrate.init_app(app) markdown(app) from app.auth import bp as auth_bp app.register_blueprint(auth_bp) from app.blog import bp as blog_bp
def app(): app = Flask(__name__) Material(app) return app