Example #1
0
# create flask wsgi app
app = Flask(__name__, template_folder="templates")
app.debug = False
app.config.update(
    {
        "SQLALCHEMY_DATABASE_URI": config.main.db_connection,
        "SESSION_COOKIE_HTTPONLY": True,
        "SESSION_COOKIE_SECURE": config.main.secure_cookie,
        "PERMANENT_SESSION_LIFETIME": timedelta(minutes=config.main.session_lifetime),
        "SECRET_KEY": config.main.secret_key,
    }
)
# mandrill middlelware
if config.email.use_mandrill:
    app.config["MANDRILL_API_KEY"] = config.email.mandrill_api_key
    app.config["MANDRILL_DEFAULT_FROM"] = config.email.from_
# add sqlalchemy middleware
db = SQLAlchemy(app)
# add flask_kvsession middleware
app.config["SESSION_KEY_BITS"] = 128
engine = create_engine("sqlite:///bitrisk/sessions.sqlite")
metadata = MetaData(bind=engine)
store = SQLAlchemyStore(engine, metadata, "kvstore")
metadata.create_all()
KVSessionExtension(store, app)
# add flask csrf middleware
csrf = SeaSurf(app)
# add rate limiting middleware
limiter = Limiter(app)
auth_limit = limiter.shared_limit("5/minute;1/second", scope="auth")
Example #2
0
    LoginManager,
    current_user,
    login_required,
    login_user,
    logout_user,
    UserMixin,
    confirm_login,
    fresh_login_required,
)

app = Flask(__name__)
app.config.from_object("config")
db = SQLAlchemy(app)

# login config
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = "login"
login_manager.login_message = u"Please log in to access this page."
login_manager.refresh_view = "reauth"

# Mandrill config
app.config["MANDRILL_API_KEY"] = "AlGPWLcyBN97zbLs59HcKw"
app.config["MANDRILL_DEFAULT_FROM"] = "noreply@passwordsharer.com"
mandrill = Mandrill(app)

# we need a better secret key
app.config["SECRET_KEY"] = "123456790"
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///app.db"

from app import models, server