Example #1
0
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.script import Manager
from flask_alchemydumps import AlchemyDumps, AlchemyDumpsCommand

# create a Flask app
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///test.db"
ftp_settings = [
    "ALCHEMYDUMPS_FTP_SERVER",
    "ALCHEMYDUMPS_FTP_USER",
    "ALCHEMYDUMPS_FTP_PASSWORD",
    "ALCHEMYDUMPS_FTP_PATH",
]
for setting in ftp_settings:
    app.config[setting] = config(setting, default=False)
db = SQLAlchemy(app)
manager = Manager(app)
alchemydumps = AlchemyDumps(app, db, basedir="tests/")
manager.add_command("alchemydumps", AlchemyDumpsCommand)


# create models
class Base(db.Model):
    __abstract__ = True
    created_on = db.Column(db.DateTime, default=db.func.now())
    updated_on = db.Column(db.DateTime, default=db.func.now(), onupdate=db.func.now())


class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
Example #2
0
import logging
import logging.config
import os

from flask import Flask, render_template

from environments.environments import environments
from releases.releases import releases

app = Flask(__name__)
app.config.from_object("observatory.settings")

for setting, value in app.config.iteritems():
    if setting in os.environ:
        app.config[setting] = os.environ.get(setting, value)

logging_conf = app.config.get("LOGGING_CONF")
if logging_conf and os.path.exists(logging_conf):
    logging.config.fileConfig(logging_conf)

logger_name = app.config.get("LOGGER_NAME")

app.register_blueprint(environments, url_prefix="/environments")

app.register_blueprint(releases, url_prefix="/releases")