示例#1
0
def storage_init_app(app):
    global storage
    if 'S3' in app.config['THROAT_CONFIG'].storage.provider:
        storage = S3Storage()
    else:
        storage = Storage()
    # XXX: flask-cloudy has a tendency to mercilessly delete the container when it doesn't have anything inside of it
    # so, to prevent errors we attempt to re-create it at startup and when uploading files.
    # We don't do this in the thumbnails container because we never delete anything from there (for now)
    if app.config['THROAT_CONFIG'].storage.provider == "LOCAL":
        pathlib.Path(app.config['THROAT_CONFIG'].storage.uploads.path).mkdir(exist_ok=True)
    storage.init_app(app)
示例#2
0
from scarlett.mod_people.controllers import people
from scarlett.mod_stats.controllers import stats
from scarlett.mod_tags.controllers import tags

app = Flask(__name__, instance_relative_config=True)
app.config.update(config)
app.secret_key = config["SECRET_KEY"]

# I like to live dangerously
libcloud.security.VERIFY_SSL_CERT = config["VERIFY_SSL_CERT"]

# Do not import assets until app has been initialized
from .util import assets

# Set up flask-cloudy
storage = Storage()
storage.init_app(app)

# Append additional allowed file extensions
extra_extensions = ["avi", "flv", "mov", "mp4", "psd", "webm", "wmv"]
storage.allowed_extensions.extend(extra_extensions)


app.jinja_env.add_extension("pyjade.ext.jinja.PyJadeExtension")
app.register_blueprint(api, url_prefix="/api")
app.register_blueprint(images, url_prefix="/images")
app.register_blueprint(main, url_prefix="/")
app.register_blueprint(people, url_prefix="/people")
app.register_blueprint(stats, url_prefix="/stats")
app.register_blueprint(tags, url_prefix="/tags")
from flask_cloudy import Storage

app = Flask(__name__)

app.config.update({
    "STORAGE_PROVIDER": "LOCAL",
    "STORAGE_CONTAINER": "./video_data/",
    "STORAGE_KEY": "",
    "STORAGE_SECRET": "",
    "STORAGE_SERVER": True,
    "STORAGE_ALLOWED_EXTENSIONS": ["flv", "avi", "rmvb", "mp4"],
    # "STORAGE_SERVER_URL": "/video_data/"
})

storage = Storage()
storage.init_app(app)


@app.context_processor
def inject_title():
    return {'title': "基于YOLO网络的行人检测研究与应用"}
    # 需要返回字典,等同于return dict(title="基于YOLO网络的行人检测研究与应用")


import views, errors

#, commands

# from flask_sqlalchemy import SQLAlchemy
# from flask_login import LoginManager
#
示例#4
0
libcloud.security.VERIFY_SSL_CERT = False


application = Flask(__name__)
application.config.from_object('config')
application.config.update({
    "STORAGE_PROVIDER": "",
    "STORAGE_CONTAINER": "",
    "STORAGE_KEY": "",
    "STORAGE_SECRET": "",
    "STORAGE_SERVER": True
})
db = SQLAlchemy(application)
storage = Storage()
storage.init_app(application)

#Model to save user information
class UserData(db.Model):
    __tablename__ = 'user'
    id = db.Column(db.Integer, primary_key=True)
    user = db.Column(db.String(128), index=True, unique=False)
    files = db.relationship('FileData',secondary='user_file_map')
    def __init__(self, user):
        self.user = user

#Model to save file information
class FileData(db.Model):
    __tablename__ = 'file'
    id = db.Column(db.Integer, primary_key=True)
    filename = db.Column(db.String(128), index=True, unique=False)