Example #1
0
    def _generate_app(self):
        app = Flask(__name__)
        app.config["PROPAGATE_EXCEPTIONS"] = True
        app.config["SQLALCHEMY_DATABASE_URI"] = "postgres:///ealgis"
        app.config["BROWSERID_LOGIN_URL"] = "/api/0.1/login"
        app.config["BROWSERID_LOGOUT_URL"] = "/api/0.1/logout"
        with open("/etc/ealgis/secret_key") as secret_fd:
            secret_key = secret_fd.read().rstrip()
        app.config["SECRET_KEY"] = secret_key
        app.config["TESTING"] = True

        login_manager = LoginManager()
        login_manager.user_loader(self.get_user_by_id)
        login_manager.init_app(app)

        browserid = BrowserID()
        browserid.user_loader(self.browserid_get_user)
        browserid.init_app(app)

        return app
Example #2
0
from flask.ext.sqlalchemy import SQLAlchemy
from pprint import pprint

## SETUP
DEBUG = True
SECRET_KEY = "development key"
USERNAME = "admin"
PASSWORD = "default"

app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:////tmp/flaskr.db"
db = SQLAlchemy(app)
app.config.from_object(__name__)

app.config["BROWSERID_LOGIN_URL"] = "/login"
app.config["BROWSERID_LOGOUT_URL"] = "/logout"
app.config["SECRET_KEY"] = "deterministic"
app.config["TESTING"] = True


class User(UserMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.UnicodeText, unique=True)
    firstname = db.Column(db.Unicode(40))
    lastname = db.Column(db.Unicode(40))
    date_register = db.Column(db.Integer)
    bio = db.Column(db.Text)
    facebook = db.Column(db.Unicode(1000))
    twitter = db.Column(db.Unicode(1000))
    website = db.Column(db.Unicode(1000))
    image = db.Column(db.LargeBinary)