Example #1
1
def create_app():
    options = {"port": 0, "unitTesting": False}
    WebConfig.config(options)

    b = Borg()
    app = Flask(__name__)
    app.config["DEBUG"] = True
    app.config["SECRET_KEY"] = b.secretKey
    app.config["SECURITY_PASSWORD_HASH"] = b.passwordHash
    app.config["SECURITY_PASSWORD_SALT"] = b.passwordSalt
    app.config["SQLALCHEMY_DATABASE_URI"] = (
        "mysql://" + b.auth_dbUser + ":" + b.auth_dbPasswd + "@" + b.auth_dbHost + "/" + b.auth_dbName
    )
    b.logger.setLevel(b.logLevel)
    b.logger.debug("Error handlers: {0}".format(app.error_handler_spec))
    app.secret_key = os.urandom(24)
    logger = logging.getLogger("werkzeug")
    logger.setLevel(b.logLevel)
    enable_debug = b.logLevel = logging.DEBUG

    cors = CORS(app)
    db.init_app(app)
    user_datastore = SQLAlchemyUserDatastore(db, User, Role)
    security = Security(app, user_datastore)

    from main import main as main_blueprint

    app.register_blueprint(main_blueprint)

    with app.app_context():
        db.create_all()

    return app
Example #2
0
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_security import Security, SQLAlchemyUserDatastore, UserMixin, RoleMixin, login_required
from flask_cors import CORS
from cairis.core.Borg import Borg
import cairis.core.BorgFactory

__author__ = "Shamal Faily"

cairis.core.BorgFactory.dInitialise()
app = Flask(__name__)
app.config["DEBUG"] = True
b = Borg()
app.config["SECRET_KEY"] = b.secretKey
app.config["SECURITY_PASSWORD_HASH"] = b.passwordHash
app.config["SECURITY_PASSWORD_SALT"] = b.passwordSalt
app.config["SQLALCHEMY_DATABASE_URI"] = (
    "mysql://" + b.auth_dbUser + ":" + b.auth_dbPasswd + "@" + b.auth_dbHost + "/" + b.auth_dbName
)

db = SQLAlchemy(app)
cors = CORS(app)

roles_users = db.Table(
    "roles_users",
    db.Column("user_id", db.Integer(), db.ForeignKey("auth_user.id")),
    db.Column("role_id", db.Integer(), db.ForeignKey("auth_role.id")),
)


class Role(db.Model, RoleMixin):
Example #3
0
import redis
from config import apiconf, REDIS_CONF, stripeconf

sys.path.append("../")

from models import *
from queue import *


PRAXYK_API_APP = Flask(__name__)  # our main flask app object
PRAXYK_API_APP.config.from_object("api.config")  # our main flask app object configured from 'config.py'

# security and auth default args
PRAXYK_API_APP.config["SECURITY_TOKEN_AUTHENTICATION_KEY"] = "token"
PRAXYK_API_APP.config["SECURITY_PASSWORD_HASH"] = apiconf["security_password_hash"]
PRAXYK_API_APP.config["SECURITY_PASSWORD_SALT"] = apiconf["security_password_salt"]
PRAXYK_API_APP.config["WTF_CSRF_ENABLED"] = False

INITIAL_USERS = apiconf["users"]  # list of initial users (root, admins, etc) to add to database upon creation

api = Api(PRAXYK_API_APP)  # our flask.restful api object that we use for routing
db = SQLAlchemy(PRAXYK_API_APP)  # this is our handle to the database
bcrypt = Bcrypt(PRAXYK_API_APP)  # used for password hashing
CORS(PRAXYK_API_APP)  # cross-site scripting
# RQ(PRAXYK_API_APP)               # redis queue

BASE_URL = "localhost"
VERSION = "/v1"

# routes
LOGIN_ROUTE = VERSION + "/login/"
Example #4
0
__author__ = "Gangeshwar"
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy

application = Flask(__name__)
application.config.from_object("config")
db = SQLAlchemy(application)
application.config["SECURITY_PASSWORD_HASH"] = "bcrypt"
application.config["SECURITY_PASSWORD_SALT"] = "$2a$16$PnnIgfMwkOjGX4SkHqSOPO"

from main import views, models
import logging, os
from flask import Flask
from flask_mail import Mail

logger = logging.getLogger("python")
logger.setLevel(logging.WARNING)
mail = Mail()
app = Flask(__name__)
app.config.from_object("config.{}Config".format(os.environ.get("SERVER_ENV", "Development")))
app.config["SQLALCHEMY_DATABASE_URI"] = app.config["SQLALCHEMY_DATABASE_URI"].format(
    os.environ.get("DB_USER"), os.environ.get("DB_PASS"), os.environ.get("DB_HOST"), os.environ.get("DB_NAME")
)
app.config["APP_NAME"] = app.config["APP_NAME"].format(os.environ.get("NAME", "API"))
app.config["SECRET_KEY"] = app.config["SECRET_KEY"].format(os.environ.get("SECRET_KEY", "SECRET"))
app.config["SECURITY_PASSWORD_SALT"] = app.config["SECURITY_PASSWORD_SALT"].format(
    os.environ.get("SECURITY_PASSWORD_SALT")
)
Example #6
0
app = Flask(__name__)
app.config.update(
    MAIL_SERVER="smtp.googlemail.com",
    MAIL_PORT=465,
    MAIL_USE_TLS=False,
    MAIL_USE_SSL=True,
    MAIL_USERNAME="votopkov.webmaster",
    MAIL_PASSWORD="alertbaka",
)

mail = Mail(app)
app.config["MAIL_DEFAULT_SENDER"] = "votopkov.webmaster@gmail.com"

app.config["SECURITY_REGISTERABLE"] = True
app.config["SECURITY_REGISTER_URL"] = "/sign_up"
app.config["SECURITY_PASSWORD_SALT"] = "zh;r9as/3yzzz~XHH!jaszLbX/,?Tr"

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

lm = LoginManager()
lm.init_app(app)
lm.session_protection = "strong"
login_serializer = URLSafeTimedSerializer(app.secret_key)
oid = OpenID(app, os.path.join(basedir, "tmp"))
lm.login_view = "login"


class Anonymous(AnonymousUserMixin):
    def __init__(self):
        self.username = "Guest"
Example #7
0
app = Flask(__name__)

app.logger.addHandler(logging.StreamHandler(sys.stdout))
app.logger.setLevel(logging.ERROR)

app.config["MONGODB_SETTINGS"] = {"db": "motoparking", "host": "mongodb://localhost:27017/motoparking"}
app.config["DEBUG"] = True

app.config["SECRET_KEY"] = "super-secret"
app.config["SECURITY_PASSWORD_HASH"] = "pbkdf2_sha512"
app.config["SECURITY_PASSWORD_SALT"] = "ytdjf.jk,upo8etsgdf,asdf34ttgewgq3g[q[epqogqjg;"
app.config["SECURITY_REGISTERABLE"] = True
app.config["SECURITY_MSG_LOGIN"] = (u"Вы не авторизованы или Вас нет в списках доступа.", "info")

if os.environ.get("MONGODB_DB"):
    app.config["MONGODB_SETTINGS"] = {"db": os.environ.get("MONGODB_DB"), "host": os.environ.get("PROD_MONGODB")}
    app.config["DEBUG"] = False
    app.config["SECRET_KEY"] = os.environ.get("SECRET_KEY")
    app.config["SECURITY_PASSWORD_SALT"] = os.environ.get("SECURITY_PASSWORD_SALT")

# app.config['SECURITY_LOGIN_USER_TEMPLATE'] = "login.html"

# app.config['SOCIAL_FACEBOOK'] = {
#     'consumer_key': '1556008511346406',
#     'consumer_secret': 'a2ed924ccd3e3cf15a392b23fdb37f25'  # TODO: change and move out
# }

# Flask-SocialBlueprint
# https://github.com/wooyek/flask-social-blueprint
app.config["SOCIAL_BLUEPRINT"] = {
Example #8
0
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.
import os
from flask import Flask, session


# db_path = os.path.abspath(
#    os.path.join(os.path.basename(__file__), "../"))

db_path = "tmp"

app = Flask(__name__)

app.config["MAILGUN_KEY"] = "#@#@#@#@"
app.config["MAILGUN_DOMAIN"] = "refstack.org"
app.config["SECRET_KEY"] = "#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@"
app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get("DATABASE_URL", "sqlite:///%s/refstack.db" % (db_path))
app.config["DEBUG"] = True
app.config["SECURITY_PASSWORD_HASH"] = "sha512_crypt"
app.config["SECURITY_PASSWORD_SALT"] = app.config["SECRET_KEY"]
app.config["SECURITY_POST_LOGIN_VIEW"] = "dashboard"
app.config["SECURITY_RECOVERABLE"] = True
app.config["SECURITY_REGISTERABLE"] = True
app.config["SECURITY_EMAIL_SENDER"] = "refstack.org"
app.config["MAIL_SERVER"] = "smtp.refstack.org"
app.config["MAIL_PORT"] = 465
app.config["MAIL_USE_SSL"] = True
app.config["MAIL_USERNAME"] = "postmaster@refstack.org"
app.config["MAIL_PASSWORD"] = "1234"
Example #9
0
import os
from tempfile import gettempdir
from flask import Flask


# Create app
app = Flask(__name__)
app.config["SECRET_KEY"] = os.environ["SECRET_KEY"]
app.config["SECURITY_PASSWORD_HASH"] = "sha512_crypt"
app.config["SECURITY_PASSWORD_SALT"] = os.environ["SECURITY_PASSWORD_SALT"]
app.config["SQLALCHEMY_DATABASE_URI"] = os.environ["SQLALCHEMY_DATABASE_URI"]
app.config["SECURITY_REGISTERABLE"] = True
app.config["SECURITY_SEND_REGISTER_EMAIL"] = False
app.config["UPLOAD_FOLDER"] = gettempdir()

import views
from FOTW.database import db


@app.before_first_request
def make_test_data():
    db.create_all()
from flask import Flask
import os
from flask.ext.sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config.from_object(__name__)
app.config["DEBUG"] = "PRODUCTION" not in os.environ
app.config["SECRET_KEY"] = os.environ.get("SECRET_KEY", "development_key")
app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get("SQL_DATABASE_URI", "sqlite:///choochootrain.db")
app.config["SECURITY_PASSWORD_HASH"] = "bcrypt"
# TODO change this later.
app.config["SECURITY_PASSWORD_SALT"] = "$2a$12$skCRnkqE5L01bHEke678Ju"
# See here for all configurable options:
# /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_security
app.config["SECURITY_REGISTERABLE"] = True
app.config["SECURITY_CHANGEABLE"] = True
app.config["SECURITY_RECOVERABLE"] = True

app.config["SECURITY_REGISTER_URL"] = "/register"
app.config["SECURITY_REGISTER_USER_TEMPLATE"] = "authentication/register.html"
app.config["SECURITY_SEND_REGISTER_EMAIL"] = False
app.config["SECURITY_LOGIN_USER_TEMPLATE"] = "authentication/login.html"
app.config["SECURITY_LOGIN_URL"] = "/signin"
app.config["SECURITY_RESET_URL"] = "/reset_password"

app.config["SECURITY_POST_LOGIN_VIEW"] = "success"
# Flask security settings: https://pythonhosted.org/Flask-Security/configuration.html
# Flask security templates that we could copy from if we want to reimplement:
# /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_security/templates/security
app.config["SECURITY_CHANGEABLE"] = True
# app.config['SECURITY_LOGIN_USER_TEMPLATE'] = 'base.html'
Example #11
0
# Create application
app = Flask(__name__)
app.config["SECRET_KEY"] = "COfwEzLtXbxwuIxkTNBcG0"

# Mail
app.config["MAIL_SERVER"] = "smtp.gmail.com"
app.config["MAIL_PORT"] = "465"
app.config["MAIL_USE_SSL"] = True
app.config["MAIL_USERNAME"] = "botflasktest@gmail.com"
app.config["MAIL_PASSWORD"] = "medabots"
app.config["MAIL_DEFAULT_SENDER"] = "naoresponder"
mail = Mail(app)


# Create dummy secrety key so we can use sessions
app.config["SECURITY_PASSWORD_SALT"] = "COfwEzLtXbxwuIxkTNBcG0"
app.config["SECURITY_PASSWORD_HASH"] = "bcrypt"
app.config["SECURITY_RECOVERABLE"] = True

# Create in-memory database
app.config["DATABASE_FILE"] = "sample_db.sqlite"
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" + app.config["DATABASE_FILE"]
app.config["SQLALCHEMY_ECHO"] = True
db = SQLAlchemy(app)

# Create directory for file fields to use
file_path = op.join(op.dirname(__file__), "static/files")

# thumb name generator function

Example #12
0
from flask import Flask
from flask.ext.security import Security, SQLAlchemyUserDatastore, UserMixin, RoleMixin
from flask.ext.sqlalchemy import SQLAlchemy
from datetime import datetime

app = Flask(__name__)
app.config[
    "SQLALCHEMY_DATABASE_URI"
] = "mysql://adminVu2uiWr:AtZ6dRthSnWt@56aee17b0c1e66574300003d-jobos.rhcloud.com:59891/tip"
app.config["SECURITY_PASSWORD_HASH"] = "pbkdf2_sha512"
app.config["SECURITY_PASSWORD_SALT"] = "requiem_for_a_dream"
app.config["SECURITY_TRACKABLE"] = True
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
app.config["WTF_CSRF_ENABLED"] = False
app.config["SECRET_KEY"] = "super secret key"
db = SQLAlchemy(app)

roles_users = db.Table(
    "roles_users",
    db.Column("user_id", db.Integer(), db.ForeignKey("auth_user.id")),
    db.Column("role_id", db.Integer(), db.ForeignKey("auth_role.id")),
)

followers = db.Table(
    "followers",
    db.Column("follower_id", db.Integer(), db.ForeignKey("auth_user.id")),
    db.Column("followed_id", db.Integer(), db.ForeignKey("auth_user.id")),
)


class Base(db.Model):
Example #13
0
from flask.ext.mail import Mail
from boto.ec2 import connect_to_region
from boto.s3.connection import S3Connection
from boto.s3.key import Key
from urllib2 import urlopen
from datetime import datetime
import json, os, random, string, subprocess

app = Flask(__name__)
app.config["DEBUG"] = False
app.config["SECRET_KEY"] = "afsdjfsafasd239"
app.config["SQLALCHEMY_DATABASE_URI"] = "mysql://ctf:fishandchipsaredelicious@localhost/ctf"
app.config["SECURITY_REGISTERABLE"] = True
app.config["SECURITY_CONFIRMABLE"] = False
app.config["SECURITY_PASSWORD_HASH"] = "plaintext"
app.config["SECURITY_PASSWORD_SALT"] = "DFa#reJK84rijhAiojOIHGFKLAJR8U"
app.config["MAIL_SERVER"] = "smtp.gmail.com"
app.config["MAIL_PORT"] = 465
app.config["MAIL_USE_SSL"] = True
app.config["MAIL_USERNAME"] = "casectf@gmail.com"
app.config["MAIL_PASSWORD"] = "correcthorsebatterystaple"
BUCKET_NAME = "case_ctf_spring_2013"
SECRET_KEY = "LgGsOQJr27ZRiBeeuRx/kSBf6fV8Qs7wH1o/djA7"
ACCESS_KEY = "AKIAJGM53Z656332A33A"
ec2 = connect_to_region("us-east-1", aws_access_key_id=ACCESS_KEY, aws_secret_access_key=SECRET_KEY)
startup_script = "#! /bin/bash"

mail = Mail(app)
db = SQLAlchemy(app)
session = db.session
Example #14
0
    app.testing = True
    app.config["SECRET_KEY"] = "super-secret"
    app.config["SECRET_KEY"] = "super-secret"
    app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///test.sqlite"
    app.config["DEFAULT_MAIL_SENDER"] = "info@site.com"
    app.config["SECURITY_REGISTERABLE"] = True
    app.config["SECURITY_CONFIRMABLE"] = True
    app.config["SECURITY_RECOVERABLE"] = True
    app.config["MAIL_SERVER"] = "smtp.gmail.com"
    app.config["MAIL_PORT"] = 465
    app.config["MAIL_USE_TLS"] = False
    app.config["MAIL_USE_SSL"] = True
    app.config["MAIL_USERNAME"] = "test"
    app.config["MAIL_PASSWORD"] = "test"
    app.config["SECURITY_PASSWORD_HASH"] = "plaintext"
    app.config["SECURITY_PASSWORD_SALT"] = "sample test here"
    app.config["SECURITY_POST_LOGIN_VIEW"] = "/"
    app.config["UPLOAD_FOLDER"] = "path/to/uploads"
    app.config["NUM_BY_PAGE"] = 10


app.wsgi_app = SharedDataMiddleware(app.wsgi_app, {"/": os.path.join(os.path.dirname(__file__), "static")})
app.wsgi_app = SharedDataMiddleware(app.wsgi_app, {"/": os.path.join(os.path.dirname(__file__), "uploads")})

# Setup mail extension
mail = Mail(app)


# init refmaker db
from tool.models import *
# Module Imports
# **********************************************************

from __future__ import division, print_function

from flask import Flask
from flask.ext.mongoengine import MongoEngine

HOSTBASE = "catalist.eastus2.cloudapp.azure.com"
# HOSTBASE = 'localhost'
PORTNO = 80
HOSTNAME = HOSTBASE + ((":" + str(PORTNO)) if PORTNO != 80 else "")

# **********************************************************
# Flask Configuration
# **********************************************************

app = Flask(__name__)

# host mongo locally
app.config["MONGODB_SETTINGS"] = {"db": "zutara-forever"}
app.config["SECRET_KEY"] = "bc5e9bf3-3d4a-4860-b34a-248dbc0ebd5c"
app.config["SECURITY_PASSWORD_SALT"] = "eddb960e-269c-4458-8e08-c1027d8b290"

db = MongoEngine(app)

import views  # /about, /mylists, etc.
import errorviews  # 404 pages, etc.
from api import api_blueprint

app.register_blueprint(api_blueprint, url_prefix="/api")
Example #16
0
from shelf import Shelf
from shelf.base import db
from shelf.plugins.library import FileAdmin
from shelf.security.models import User, Role

import admin
import model

app = Flask(__name__)
app.debug = True
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///blog.db"
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
app.config["SECRET_KEY"] = "notasecret"
app.config["SECURITY_REGISTERABLE"] = True
app.config["SECURITY_PASSWORD_HASH"] = "bcrypt"
app.config["SECURITY_PASSWORD_SALT"] = "mysalt"  # "hash_123678*",
app.config["SECURITY_SEND_REGISTER_EMAIL"] = False

app.config["APP_ROOT"] = os.path.dirname(os.path.abspath(__file__))
app.config["APP_STATIC"] = os.path.join(app.config["APP_ROOT"], "static")
app.config["MEDIA_ROOT"] = os.path.join(app.config["APP_STATIC"], "media")
app.config["MEDIA_URL"] = "/static/media/"

try:
    os.makedirs(app.config["MEDIA_ROOT"])
except OSError:
    pass

with app.app_context():
    db.init_app(app)
    db.app = app
from flask import Flask, redirect, render_template, request, url_for, session, flash
from DBConnect import DBConnect
from functools import wraps
from werkzeug.security import generate_password_hash, check_password_hash
from flask_mail import Mail, Message
from itsdangerous import URLSafeTimedSerializer

app = Flask(__name__)
app.config["SECRET_KEY"] = "helloworld"
app.config["SECURITY_PASSWORD_SALT"] = "hello_world"


def generate_confirmation_token(email):
    serializer = URLSafeTimedSerializer(app.config["SECRET_KEY"])
    return serializer.dumps(email, salt=app.config["SECURITY_PASSWORD_SALT"])


def confirm_token(token, expiration=86400):
    serializer = URLSafeTimedSerializer(app.config["SECRET_KEY"])
    try:
        email = serializer.loads(token, salt=app.config["SECURITY_PASSWORD_SALT"], max_age=expiration)
    except:
        return False
    return email


# ===============================================================
# ===================== Email configuration =====================
# For simplicity, I just used my gmail account, and because
# gmail was being a c when tyring to set up a new account.
Example #18
0
from functools import wraps
from os import environ

from flask import Flask
from flask import request, Response
from flask.ext.security.utils import encrypt_password, verify_password
from flask.ext.sqlalchemy import SQLAlchemy
from flask_restful import Resource, Api

app = Flask(__name__)

app.config.from_object(environ["APP_SETTINGS"])
app.config["SECURITY_PASSWORD_SALT"] = environ.get("SECURITY_PASSWORD_SALT")

api = Api(app)
db = SQLAlchemy(app)

import models


def check_auth(email, password):
    """
    This function is called to check if a username & password combination is valid.
    """
    users_with_that_email = models.User.query.filter_by(email=email)
    db_password = ""
    if users_with_that_email.count() > 0:
        db_password = users_with_that_email[0].password

    return verify_password(password, db_password)
Example #19
0
    application.config["SQLALCHEMY_DATABASE_URI"] = conf.SQLALCHEMY_DATABASE_URI
    if "postgres" in conf.SQLALCHEMY_DATABASE_URI:
        application.config["SQLALCHEMY_POOL_SIZE"] = 15
        application.config["SQLALCHEMY_MAX_OVERFLOW"] = 0

scheme, domain, _, _, _ = urlsplit(conf.PLATFORM_URL)
application.config["SERVER_NAME"] = domain
application.config["PREFERRED_URL_SCHEME"] = scheme

set_logging(conf.LOG_PATH, log_level=conf.LOG_LEVEL)

# Create secrey key so we can use sessions
application.config["SECRET_KEY"] = getattr(conf, "WEBSERVER_SECRET", None)
if not application.config["SECRET_KEY"]:
    application.config["SECRET_KEY"] = os.urandom(12)

application.config["SECURITY_PASSWORD_SALT"] = getattr(conf, "SECURITY_PASSWORD_SALT", None)
if not application.config["SECURITY_PASSWORD_SALT"]:
    application.config["SECURITY_PASSWORD_SALT"] = os.urandom(12)

db = SQLAlchemy(application)

# Create the Flask-Restless API manager.
manager = flask_restless.APIManager(application, flask_sqlalchemy_db=db)


def populate_g():
    from flask import g

    g.db = db
    g.app = application
Example #20
0

app = Flask(__name__)

app.config["DEBUG"] = True
app.config["SECRET_KEY"] = "todo-app-secret-key"

# for postgresql
# app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://postgres:ID@localhost/flask_example'
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///appdata.db"

# Config values for Flask-Security.
# We're using PBKDF2 with salt.
app.config["SECURITY_PASSWORD_HASH"] = "pbkdf2_sha512"
# Replace this with your own salt.
app.config["SECURITY_PASSWORD_SALT"] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

app.config["SECURITY_EMAIL_SENDER"] = "no-reply@example.com"
# SMTP Server settings (using https://github.com/ThiefMaster/maildump)
app.config["MAIL_SERVER"] = "localhost"
app.config["MAIL_PORT"] = 1025
app.config["MAIL_USE_SSL"] = False
app.config["MAIL_USERNAME"] = ""
app.config["MAIL_PASSWORD"] = ""

# for app registration, confirmation by email
app.config["SECURITY_REGISTERABLE"] = True
app.config["SECURITY_CONFIRMABLE"] = True
app.config["SECURITY_RECOVERABLE"] = True

Example #21
0

app.config["DEBUG"] = False
app.config["TOKEN"] = settings.TOKEN
app.config["SQLALCHEMY_DATABASE_URI"] = db_str
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
app.config["SQLALCHEMY_BINDS"] = db_binds
app.config["SECRET_KEY"] = settings.SECURITY_SECRET

app.config["SECURITY_LOGIN_URL"] = "/security/login"
app.config["SECURITY_LOGOUT_URL"] = "/security/logout"
app.config["SECURITY_REGISTER_URL"] = "/security/register"
app.config["SECURITY_REGISTERABLE"] = True
app.config["SECURITY_SEND_REGISTER_EMAIL"] = False
app.config["SECURITY_PASSWORD_HASH"] = "sha512_crypt"
app.config["SECURITY_PASSWORD_SALT"] = settings.SECURITY_SECRET
app.config["SECURITY_LOGIN_USER_TEMPLATE"] = "/security/login.html"
app.config["SECURITY_REGISTER_USER_TEMPLATE"] = "/security/register.html"
app.config["SECURITY_POST_REGISTER_VIEW"] = "/admin"

db = SQLAlchemy(app)


cache = RedisCache(
    host=settings.REDIS_HOST,
    port=settings.REDIS_PORT,
    db=settings.REDIS_DB,
    password=settings.REDIS_PASSWORD,
    key_prefix="wechat",
)
Example #22
0
app = Flask(__name__)

app.config["DEBUG"] = False
app.config["SECRET_KEY"] = secret_key

# MongoDB Config
app.config["MONGODB_DB"] = mongo_db
app.config["MONGODB_HOST"] = mongo_host
app.config["MONGODB_PORT"] = mongo_port

# Security Features
app.config["SECURITY_REGISTERABLE"] = user_enable_registration
app.config["SECURITY_TRACKABLE"] = user_enable_tracking
app.config["SECURITY_EMAIL_SENDER"] = user_from_email
app.config["SECURITY_PASSWORD_HASH"] = pwhash
app.config["SECURITY_PASSWORD_SALT"] = salt
app.config["SECURITY_CONFIRMABLE"] = True
app.config["SECURITY_EMAIL_SUBJECT_REGISTER"] = user_register_email_subject

# Email
app.config["MAIL_SERVER"] = mail_url
app.config["DEBUG"] = False
app.config["MAIL_PORT"] = mail_port
app.config["MAIL_USE_SSL"] = mail_SSL
app.config["MAIL_USE_TLS"] = mail_TLS
app.config["MAIL_USERNAME"] = mail_user
app.config["MAIL_PASSWORD"] = mail_pass
app.config["MAIL_SUPPRESS_SEND"] = False


# Create database connection object
Example #23
0
from flask import Flask

app = Flask(__name__)


############### Load config #################
app.config["SECRET_KEY"] = "hello world"
app.config["DATABASE_FILE"] = "/tmp/database.db"
app.config["TMP_PICTURE_FOLDER"] = "/tmp/liotyphserver_tmp/"

app.config["SECURITY_PASSWORD_HASH"] = "sha512_crypt"
app.config["SECURITY_PASSWORD_SALT"] = "fhasdgihwntlgy8f"


import liotyphserver.model
import liotyphserver.views