Example #1
0
        if isinstance(obj, basestring) == False:

            try:
                iterable = iter(obj)
            except TypeError:
                pass
            else:
                return list(iterable)

        return JSONEncoder.default(self, obj)


# App Configuration
# http://stackoverflow.com/a/14826195
UPLOAD_FOLDER = "catalog/static/images"
ALLOWED_EXTENSIONS = ["png", "jpg"]
APP_ROOT = os.path.dirname(os.path.abspath(__file__))
APP_STATIC = os.path.join(APP_ROOT, "static")
APP_IMAGES = os.path.join(APP_STATIC, "images")
APP_CLIENT_SECRET = os.path.join(APP_ROOT, "client_secret.json")
APP_DATABASE = "sqlite:///catalog/catalog.db"


app.config["APP_IMAGES"] = APP_IMAGES
app.config["APP_STATIC"] = APP_STATIC
app.config["APP_ROOT"] = APP_ROOT
app.config["APP_DATABASE"] = APP_DATABASE
app.config["UPLOAD_FOLDER"] = UPLOAD_FOLDER
app.config["ALLOWED_EXTENSIONS"] = ALLOWED_EXTENSIONS
app.config["APP_CLIENT_SECRET"] = APP_CLIENT_SECRET
app.json_encoder = ModelsEncoder
Example #2
0
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

    shlf = Shelf(app)
    shlf.init_db(db)
    shlf.init_admin()