Example #1
0
import os
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.restless import APIManager
from flask.ext.admin import Admin

ALLOWED_EXTENSIONS = set(["txt", "pdf", "png", "jpg", "jpeg", "gif", "doc", "docx", "mov", "mp4", "mp3", "wav"])

app = Flask(__name__)
app.config["UPLOAD_FOLDER"] = os.path.realpath(".") + "/uploads/"
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///../cb.db"
app.config["WTF_CSRF_SECRET_KEY"] = "random key for form"
app.config["USER"] = "demo"
app.config["PIN"] = "demo"
db = SQLAlchemy(app)
manager = APIManager(app, flask_sqlalchemy_db=db)
admin = Admin(app)

app.secret_key = "some_random_key"

from casting_bridge.catalog.views import catalog

app.register_blueprint(catalog)

db.create_all()
Example #2
0
import logging

try:
    import json
except ImportError:
    import simplejson as json


app = Flask(__name__)

config_file = os.path.join(os.path.dirname(__file__), "config.json")
with open(config_file) as f:
    config = json.loads(f.read())
    app.config["SECRET_KEY"] = config["secret_key"]
    app.config["DB_NAME"] = config["db_name"]
    app.config["TABLE_NAME"] = config["table_name"]
    app.config["LOG_FILE"] = config["logfile"]
    app.config["USER"] = {"LOGIN": config["api_login"], "PASSWORD": config["api_password"]}

login_manager = LoginManager()
login_manager.init_app(app)


import views


if __name__ == "__main__":
    logging.basicConfig(
        format="[%(levelname)s]%(asctime)s: %(message)s", filename=app.config["LOG_FILE"], level=logging.INFO
    )
    app.run(debug=True)