예제 #1
0
from flask_uploads import UploadSet, IMAGES,patch_request_class, AllExcept

upFile = UploadSet('upFile',extensions=AllExcept(()))


def uploadFile(request):
    if request.method == 'POST' and 'videoFile'  in request.files:
      videoName=request.form['fileName']
      request.files['videoFile'].filename=videoName
      filename = upFile.save(request.files['videoFile'])
      # file_url = upFile.url(filename)
      return str(filename)+' don'
    elif request.method == 'POST' and 'imageFile'  in request.files:
      imageName=request.form['fileName']
      request.files['imageFile'].filename=imageName
      filename = upFile.save(request.files['imageFile'])
      # file_url = upFile.url(filename)
      return str(filename)+' don'
    else:
      return 'error'
예제 #2
0
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from flask_login import LoginManager
from flask_uploads import configure_uploads, patch_request_class, UploadSet, AllExcept, SCRIPTS, EXECUTABLES
from flask_mail import Mail

from config import Config


db = SQLAlchemy()
migrate = Migrate()
login_manager = LoginManager()
mail = Mail()
user_files = UploadSet('files', AllExcept(SCRIPTS + EXECUTABLES))


def create_app(config_class=Config):
    app = Flask(__name__)
    app.config.from_object(config_class)

    db.init_app(app)
    migrate.init_app(app, db)
    login_manager.init_app(app)
    mail.init_app(app)
    configure_uploads(app, (user_files))
    # patch_request_class(app, 1 * 1024 * 1024 * 1024)

    from app.main import bp as main_bp
    app.register_blueprint(main_bp)
예제 #3
0
 def test_custom_iterables(self):
     assert 'txt' in ALL
     assert 'exe' in ALL
     ax = AllExcept(['exe'])
     assert 'txt' in ax
     assert 'exe' not in ax
예제 #4
0
from flask_jwt_oidc import JwtManager
from flask_sqlalchemy import SQLAlchemy
from flask_uploads import UploadSet, AllExcept, EXECUTABLES, SCRIPTS
from flask_restplus import Api

from .config import Config

db = SQLAlchemy()
jwt = JwtManager()
api = Api(prefix=Config.BASE_PATH,
          doc='{}/'.format(Config.BASE_PATH),
          default='mds',
          default_label='MDS related operations')

documents = UploadSet('document', AllExcept(EXECUTABLES + SCRIPTS))
예제 #5
0
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from flask_uploads import UploadSet, configure_uploads, AllExcept, SCRIPTS, EXECUTABLES
from config import Config

app = Flask(__name__)
app.config.from_object(Config)
db = SQLAlchemy(app)
migrate = Migrate(app, db)
upload_set = UploadSet(
    default_dest=lambda app: 'app/' + app.config['UPLOAD_FOLDER'],
    extensions=AllExcept(SCRIPTS + EXECUTABLES))
uploads = configure_uploads(app, upload_set)

from app import routes, models
예제 #6
0
migrate = Migrate(compare_type=True)
login = LoginManager()
login.login_view = 'users.login'
login.login_message = _l('Por favor, loguearse para ver esta página.')
mail = Mail()
bootstrap = Bootstrap()
moment = Moment()
babel = Babel()
# we don't want the cache expire, so we'll use a number stupidly high
# to avoid the expiration
cache = Cache(config={
    'CACHE_TYPE': 'simple',
    'CACHE_DEFAULT_TIMEOUT': 9999999999
})
scheduler = BackgroundScheduler()
files_collection = UploadSet('uploads', AllExcept(('exe', 'iso')))


def create_app(config_class=Config):
    app = Flask(__name__)
    app.config.from_object(config_class)
    cache.init_app(app)
    db.init_app(app)
    migrate.init_app(app, db)
    login.init_app(app)
    mail.init_app(app)
    bootstrap.init_app(app)
    moment.init_app(app)
    babel.init_app(app)
    configure_uploads(app, files_collection)
예제 #7
0
elif app.config["ENV"] == "testing":
    app.config.from_object("config.TestingConfig")
else:
    app.config.from_object("config.DevelopmentConfig")
print(f'ENV is set to: {app.config["ENV"]}')


db = SQLAlchemy(app)

bcrypt = Bcrypt(app)
login_manager = LoginManager(app)
login_manager.login_view = 'bp_users.login'
login_manager.login_message_category = 'info'
login_manager.session_protection = None

filehost = UploadSet('filehost', AllExcept(SCRIPTS + EXECUTABLES))
configure_uploads(app, filehost)
patch_request_class(app, size=500*1024*1024)

dropzone = Dropzone(app)



from portfolio.bp_main.routes import bp_main

app.register_blueprint(bp_main)

from portfolio.bp_users.routes import bp_users

app.register_blueprint(bp_users)
예제 #8
0
# 3rd party imports
from flask_sqlalchemy import SQLAlchemy
#from flask_msearch import Search
from flask_migrate import Migrate
from flask_mail import Mail
from flask_login import LoginManager
from flask_uploads import UploadSet, configure_uploads, IMAGES, ALL, AllExcept, SCRIPTS, AUDIO, EXECUTABLES

db = SQLAlchemy()
#search = Search()
migrate = Migrate()
mail = Mail()
login_manager = LoginManager()
images = UploadSet('images', IMAGES)
documents = UploadSet('documents', ALL)  #filter out allowed docs
uploads = UploadSet('uploads', AllExcept(SCRIPTS + EXECUTABLES + AUDIO))
예제 #9
0
import os

from app import app
from config import basedir
from flask import request
from flask_uploads import UploadSet, configure_uploads, AllExcept, SCRIPTS, EXECUTABLES, IMAGES
from flask_restful import abort, Resource
from PIL import Image
from resizeimage import resizeimage

uploads = UploadSet('uploads', AllExcept(SCRIPTS + EXECUTABLES))
interactions_upload_set = UploadSet('interactions', AllExcept(SCRIPTS + EXECUTABLES))
medical_upload_set = UploadSet('medical', AllExcept(SCRIPTS + EXECUTABLES))
photos_sub = 'photos'
photos = UploadSet(photos_sub, IMAGES)

interactions_sub = 'interactions'
medical_sub = 'medical'

dest = os.path.join(basedir, 'app', 'static')

app.config['UPLOADS_DEFAULT_DEST'] = dest
configure_uploads(app, photos)
configure_uploads(app, interactions_upload_set)
configure_uploads(app, medical_upload_set)


class Upload(Resource):
    """HTML for this requst should look something like,

    <form method=POST enctype=multipart/form-data action=something>
from flask_socketio import SocketIO
from flask_uploads import UploadSet, configure_uploads, AllExcept, SCRIPTS, EXECUTABLES
import os

# Base directory of webapp - should return ...somefolder/Lie_to_me
basedir = os.path.abspath(os.path.dirname(__file__))

# Path to FFMPEG/FFPROBE - set this to FFMPEG PATH in Windows/Mac
if os.name == 'nt':
    FFMPEG_PATH = os.path.join(basedir, 'apps', 'ffmpeg.exe')
    FFPROBE_PATH = os.path.join(basedir, 'apps', 'ffprobe.exe')
else:
    FFMPEG_PATH = os.path.join(basedir, 'apps', 'ffmpeg')
    FFPROBE_PATH = os.path.join(basedir, 'apps', 'ffprobe')

jsglue = JSGlue()
video = UploadSet('videos', AllExcept(SCRIPTS + EXECUTABLES))

app = Flask(__name__)

# app.config['UPLOADED_VIDEOS_DEST'] = 'uploads'
app.config['UPLOADED_VIDEOS_DEST'] = os.path.join(basedir, 'static', 'data',
                                                  'uploads')
app.config['SECRET_KEY'] = "VgGbw86h5A37B0Q6EA4t"

configure_uploads(app, video)
jsglue.init_app(app)
socketio = SocketIO(app)

import lie_to_me.routes
import lie_to_me.websockets