def setup(app): # public configs, from config.yaml with open('config.yaml', 'r') as config_file: app.config.update(yaml.load(config_file)) app.config['DEBUG'] = distutils.util.strtobool(ENV.get('DEBUG', False)) # extensions flask_misaka.Misaka(app) flask_scss.Scss(app, static_dir='static', asset_dir='static') cache = Cache(app, config={'CACHE_TYPE': 'simple'}) return cache
maintenance mode displaying an information page only. Created as early as possible to ensure it is called before login_manager.login_user """ if os.path.exists(APP.config['MAINTENANCE_FILE_PATH']): APP.config['MAINTENANCE_MODE'] = True if ('maintenance' not in flask.request.path and 'static' not in flask.request.path): return flask.redirect(flask.url_for('maintenance')) log_manager.LogManager(APP) email_manager.EmailManager(APP) login_manager.LOGIN_MANAGER.init_app(APP) misaka.Misaka(APP) # markdown.Markdown(APP) APP.sms_manager = sms_manager.SmsManager() LOG = APP.log_manager.log_main APP.register_blueprint(all_views.ADMIN) APP.register_blueprint(all_views.ADMIN_ANNOUNCEMENTS) APP.register_blueprint(all_views.ADMIN_DATA) APP.register_blueprint(all_views.ADMIN_PHOTOS) APP.register_blueprint(all_views.ADMIN_POSTAGE) APP.register_blueprint(all_views.ADMIN_TICKETS) APP.register_blueprint(all_views.ADMIN_USERS) APP.register_blueprint(all_views.ADMIN_VOUCHERS) APP.register_blueprint(all_views.AJAX)
import datetime import bcrypt import flask import flask_login import flask_sqlalchemy import flask_wtf import wtforms import flask_misaka from slugify import slugify app = flask.Flask(__name__) app.config.from_envvar('KILOBLOG_SETTINGS') flask_misaka.Misaka(app) db = flask_sqlalchemy.SQLAlchemy(app) login_manager = flask_login.LoginManager() login_manager.init_app(app) login_manager.login_view = 'login' class Post(db.Model): """ Args: title (str): Title of the blog post for display at the top of the page. slug (str): Unchanging url slug based on title. content (str): Blog post content (eventually this will be in markdown). pub_date (datetime.date): Date that this blog was initially published. Returns: New post model object.