app.config['APPLICATION_ROOT'] = APPLICATION_ROOT app.config['SERVER_NAME'] = SERVER_NAME app.config['USE_X_SENDFILE'] = USE_X_SENDFILE app.config['UPLOADED_IMAGERY_DEST'] = UPLOADED_IMAGERY_DEST # Initialize Celery celery = Celery(app.name, broker=CELERY_BROKER_URL) celery.conf.update({ 'broker_url': CELERY_BROKER_URL, 'result_backend': CELERY_RESULT_BACKEND, 'task_default_queue': CELERY_DEFAULT_QUEUE, 'task_track_started': True }) # Initialize Tus tm = tus_manager(app, upload_url='/imagery/upload', upload_folder=app.config['UPLOADED_IMAGERY_DEST']) # overwrite tus_max_file_size to support big(ger) files tm.tus_max_file_size = 17179869184 # 16GB # Initialize Flask-Uploads imagery = UploadSet('imagery', ('tif', 'tiff')) configure_uploads(app, (imagery,)) @tm.upload_file_handler def upload_file_handler(upload_file_path, filename=None, remote=False): id = str(uuid.uuid4()) task_info = os.path.join(IMAGERY_PATH, id, 'ingest.task') os.mkdir(os.path.dirname(task_info))
@app.route('/products/inactive', methods=['GET']) def products_inactive(): return render_template('products_paginated.html', active_mode=False) @app.route('/products/create', methods=['GET']) def products_create(): return render_template('products_create.html') ################################## # Import ################################## tm = tus_manager(app, upload_url='/products-csv-upload', upload_folder='uploads/') @tm.upload_file_handler def upload_file_hander(upload_file_path, filename): from celery_tasks import process_csv if settings.CELERY_ENABLED: process_csv.apply_async(args=[upload_file_path], queue='flask-crud-celery') else: process_csv(upload_file_path) return filename
from pathlib import Path import yaml app = Flask(__name__) app_settings = os.getenv('APP_SETTINGS', 'server.config.DevelopmentConfig') app.config.from_object(app_settings) if app.config.get('UPLOAD_TYPE') == 'file': storage = FileStorage(app.config.get('UPLOAD_FOLDER')) elif app.config.get('UPLOAD_TYPE') == 'aws': storage = S3Storage(app.config.get('AWS_BUCKET')) tm = tus_manager(app, upload_url='/uploads', upload_folder=app.config.get('UPLOAD_FOLDER'), overwrite=True, upload_finish_cb=None, storage=storage) db = SQLAlchemy(app) redis_db = redis.StrictRedis(host=app.config.get('REDIS_SERVERNAME'), port=6379, db=0, password='******') es_client = Elasticsearch() connections.create_connection(hosts=['elasticsearch']) from .work import work as work_blueprint app.register_blueprint(work_blueprint)
# !/usr/bin/env python # -*- coding:utf8 -*- """ :author: wujiangbin :copyright: (c) 2020 - 2021 BeiJing ZhiTuShiKong Technology CO.,Ltd. 北京星球时空科技有限公司 All rights reserved. """ from flask import Flask #import upload from flask_tus import tus_manager app = Flask(__name__) tus_manager(app) app.run("0.0.0.0", 4004)
# !/usr/bin/env python # -*- coding:utf8 -*- # # Copyright (c) 2019 - 2040 BeiJing ZhiTuShiKong Technology CO.,Ltd. # 北京智图时空科技有限公司 # # All rights reserved. # from flask import Flask, render_template, send_from_directory from flask_tus import tus_manager import os app = Flask(__name__) tm = tus_manager(app, upload_url='/file-upload', upload_folder='uploads/') app.run("0.0.0.0", 1080)