def create_app(TINYLIBRARY_SQLITE3_PATH='/tmp/tinylibrary.db'): """Create a SQLite-backed app and populates it for local development""" app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + TINYLIBRARY_SQLITE3_PATH app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True #XXX:??? app.config.from_pyfile('secrets.py') db.init_app(app) login_manager.login_view = 'tinylibrary_app.login' login_manager.init_app(app) bcrypt.init_app(app) app.register_blueprint(tinylibrary_app) # setup logging from logging.handlers import RotatingFileHandler file_handler = RotatingFileHandler('flask.log', maxBytes=1024 * 1024 * 100, backupCount=20) file_handler.setLevel(logging.ERROR) formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") file_handler.setFormatter(formatter) app.logger.addHandler(file_handler) return app
def create_app(): app = Flask(__name__) # DB設定の読み込み app.config.from_object('config.Config') app.config['SECRET_KEY'] = os.urandom(24) db.init_app(app) login_manager.init_app(app) app.register_blueprint(skipcafe_view.app) return app
def create_app(): app = Flask(__name__, static_folder=r_path('static'), template_folder=r_path('templates')) if getattr(sys, 'frozen', False): basedir = os.path.dirname(sys.executable) else: basedir = os.path.abspath(os.path.dirname(__file__)) # bootstrap = Bootstrap(app) pagedown = PageDown(app) app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + r_path( 'data.sqlite') # Autoreload if templates change app.config['TEMPLATES_AUTO_RELOAD'] = True # flask_upload settings # app.config['MAX_CONTENT_LENGTH'] = 500 * 1024 * 1024 # Remove Upload limit. FIX ISSUE app.config['UPLOADED_FILES_DEST'] = r_path('static/multimedia') app.config['UPLOADED_FILES_ALLOW'] = mdal app.config['SECRET_KEY'] = os.urandom(24) # Intiating extensions before registering blueprints moment = Moment(app) qrc = QRcode(app) configure_uploads(app, files) login_manager.init_app(app) db.init_app(app) datepicker( app, local=['static/css/jquery-ui.min.css', 'static/jquery-ui.min.js']) colorpicker(app, local=['static/css/spectrum.css', 'static/spectrum.js']) fontpicker(app, local=[ 'static/jquery-ui.min.js', 'static/css/jquery-ui.min.css', 'static/webfont.js', 'static/webfont.select.js', 'static/css/webfont.select.css' ]) # Register blueprints app.register_blueprint(administrate) app.register_blueprint(core) app.register_blueprint(cust_app) app.register_blueprint(errorsh_app) app.register_blueprint(manage_app) return app
import os from flask import Flask from flask_socketio import SocketIO from database import db, login_manager from authTest import authTest_blueprint from storyRoute import story_blueprint from chapterRoute import chapter_blueprint from APIRoute import API_blueprint from APIUserRoute import APIUser_blueprint project_dir = os.path.dirname(os.path.abspath(__file__)) database_file = 'mysql+pymysql://root:@localhost/fypdatabase' app = Flask(__name__, template_folder='./static/templates') app.config['SECRET_KEY'] = 'secret!' app.config["SQLALCHEMY_DATABASE_URI"] = database_file socketio = SocketIO(app) db.init_app(app) login_manager.init_app(app) login_manager.login_view = "authTest.loginHandler" app.register_blueprint(authTest_blueprint) app.register_blueprint(story_blueprint) app.register_blueprint(chapter_blueprint) app.register_blueprint(API_blueprint) app.register_blueprint(APIUser_blueprint) if __name__ == "__main__": app.run(debug=True)