Esempio n. 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)
Esempio n. 2
0
# init flask assets
assets_env = Environment()

debug_toolbar = DebugToolbarExtension()
csrf = CSRFProtect()

login_manager = LoginManager()
login_manager.login_view = "auth.login"
login_manager.login_message_category = "warning"
login_manager.session_protection = "strong"
# login_manager.user_loader is registered in controllers/auth.

# TODO:
login_manager.refresh_view = "auth.reauth"
login_manager.needs_refresh_message = (
    u"To protect your account, please reauthenticate to access this page."
)
login_manager.needs_refresh_message_category = "info"

token = Token()

# socketio = SocketIO()
rq2 = RQ()
admin = AdminDashboard()
mail = Mail()
limiter = Limiter(key_func=get_remote_address)
stripe = Stripe()
sentry = Sentry()
hashids = HashIds()
storage = Storage()
Esempio n. 3
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")
Esempio n. 4
0
def app_storage():
    return Storage(app=App())
Esempio n. 5
0
from sqlalchemy.orm import scoped_session

from flask_cloudy import Storage

from celery import Celery

from vwadaptor.settings import DevConfig, ProdConfig

if os.environ.get("VWADAPTOR_ENV") == 'prod':
    config = ProdConfig
else:
    config = DevConfig

#import time
#time.sleep(12)
db_engine = create_engine(config.SQLALCHEMY_DATABASE_URI)
Session = sessionmaker(bind=db_engine)
db = Session()


storage_extra = config.STORAGE_EXTRA
storage = Storage(provider=config.STORAGE_PROVIDER, key=config.STORAGE_KEY,
                  secret=config.STORAGE_SECRET, container=config.STORAGE_CONTAINER,
                  allowed_extensions=config.STORAGE_ALLOWED_EXTENSIONS,**storage_extra)



celery= Celery('vwadaptor',
                broker=config.CELERY_BROKER_URL,
                backend=config.CELERY_RESULT_BACKEND,CELERYD_POOL_RESTARTS=True)
from flask import Flask
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
Esempio n. 7
0
from flask_sqlalchemy import SQLAlchemy

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)