コード例 #1
0
    def create_app(self):
        """Create the app."""
        from flask_iiif import IIIF
        from flask_restful import Api
        from flask_iiif.cache.simple import ImageSimpleCache

        app = Flask(__name__)
        app.config['DEBUG'] = True
        app.config['TESTING'] = True
        app.config['SERVER_NAME'] = "shield.worker.node.1"
        app.config['SITE_URL'] = "http://shield.worker.node.1"
        app.config['IIIF_CACHE_HANDLER'] = ImageSimpleCache()
        app.config['PRESERVE_CONTEXT_ON_EXCEPTION'] = False
        app.logger.disabled = True

        api = Api(app=app)

        iiif = IIIF(app=app)

        iiif.uuid_to_image_opener_handler(self.create_image)

        def api_decorator_test(*args, **kwargs):
            if 'decorator' in kwargs.get('uuid'):
                abort(403)

        iiif.api_decorator_handler(api_decorator_test)

        iiif.init_restful(api)
        return app
コード例 #2
0
ファイル: helpers.py プロジェクト: tind/flask-iiif
    def create_app(self):
        """Create the app."""
        from flask_iiif import IIIF
        from flask_restful import Api
        from flask_iiif.cache.simple import ImageSimpleCache

        app = Flask(__name__)
        app.config["DEBUG"] = True
        app.config["TESTING"] = True
        app.config["SERVER_NAME"] = "shield.worker.node.1"
        app.config["SITE_URL"] = "http://shield.worker.node.1"
        app.config["IIIF_CACHE_HANDLER"] = ImageSimpleCache()
        app.logger.disabled = True

        api = Api(app=app)

        iiif = IIIF(app=app)

        iiif.uuid_to_image_opener_handler(self.create_image)

        def api_decorator_test(*args, **kwargs):
            if "decorator" in kwargs.get("uuid"):
                abort(403)

        iiif.api_decorator_handler(api_decorator_test)

        iiif.init_restful(api)
        return app
コード例 #3
0
ファイル: ext.py プロジェクト: slint/invenio-iiif
 def init_app(self, app):
     """Flask application initialization."""
     super(InvenioIIIFAPI, self).init_app(app)
     ext = IIIF(app=app)
     api = Api(app=app)
     ext.init_restful(api, prefix=app.config['IIIF_API_PREFIX'])
     ext.uuid_to_image_opener_handler(image_opener)
     ext.api_decorator_handler(protect_api)
コード例 #4
0
ファイル: ext.py プロジェクト: slint/invenio-iiif
 def init_app(self, app):
     """Flask application initialization."""
     super(InvenioIIIFAPI, self).init_app(app)
     ext = IIIF(app=app)
     api = Api(app=app)
     ext.init_restful(api, prefix=app.config['IIIF_API_PREFIX'])
     ext.uuid_to_image_opener_handler(image_opener)
     ext.api_decorator_handler(protect_api)
コード例 #5
0
ファイル: ext.py プロジェクト: kprzerwa/cds-videos
 def init_app(self, app):
     """Flask application initialization."""
     api = Api(app=app)
     ext = IIIF()
     ext.init_app(app)
     ext.uuid_to_image_opener_handler(image_opener)
     ext.init_restful(api, prefix='/iiif/')
     return app
コード例 #6
0
 def init_app(self, app):
     """Flask application initialization."""
     api = Api(app=app)
     app.config['IIIF_CACHE_HANDLER'] = simple.ImageSimpleCache()
     ext = IIIF()
     ext.init_app(app)
     ext.uuid_to_image_opener_handler(image_opener)
     ext.init_restful(api, prefix='/iiif/')
     return app
コード例 #7
0
ファイル: app.py プロジェクト: jirikuncar/iugw2015
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get(
    'SQLALCHEMY_DATABASE_URI', 'sqlite:////tmp/test.db'
)
db = SQLAlchemy(app)
redis = Redis(host=os.environ.get('REDIS_HOST', 'localhost'), port=6379)
celery = Celery('app', broker=os.environ.get(
    'CELERY_BROKER_URL', 'redis://localhost:6379'
))

# Init the iiif extension
iiif = IIIF(app=app)
# Init the restful api
api = Api(app=app)
# Init restful api to flask-iiif
iiif.init_restful(api)


# Where iiif will find the images in our case `./images`
def uuid_to_source(uuid):
    image_path = os.path.join('./', 'images')
    return os.path.join(image_path, uuid)

# Init the opener function
iiif.uuid_to_image_opener_handler(uuid_to_source)

# Initialize the cache
app.config['IIIF_CACHE_HANDLER'] = redis


@celery.task()
コード例 #8
0
from flask_iiif import IIIF
from flask_iiif.cache.simple import ImageSimpleCache
from flask_restful import Api
from iiif_prezi.factory import ManifestFactory

from index import DatabaseRepository, FilesystemRepository

SearchHit = namedtuple("SearchHit",
                       ("match", "before", "after", "annotations"))

app = flask.Flask('hocrviewer',
                  static_folder='./vendor/mirador',
                  static_url_path='/static')
ext = IIIF(app=app)
api = Api(app=app)
ext.init_restful(api, prefix="/iiif/image/")
repository = None
logger = logging.getLogger(__name__)


class ApiException(Exception):
    status_code = 500

    def __init__(self, message, status_code=None, payload=None):
        Exception.__init__(self)
        self.message = message
        if status_code is not None:
            self.status_code = status_code
        self.payload = payload

    def to_dict(self):
コード例 #9
0
ファイル: app.py プロジェクト: drjova/iugw2015
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get(
    'SQLALCHEMY_DATABASE_URI', 'sqlite:////tmp/test.db')
db = SQLAlchemy(app)
redis = Redis(host=os.environ.get('REDIS_HOST', 'localhost'), port=6379)
celery = Celery('app',
                broker=os.environ.get('CELERY_BROKER_URL',
                                      'redis://localhost:6379'))

# Init the iiif extension
iiif = IIIF(app=app)
# Init the restful api
api = Api(app=app)
# Init restful api to flask-iiif
iiif.init_restful(api)


# Where iiif will find the images in our case `./images`
def uuid_to_source(uuid):
    image_path = os.path.join('./', 'images')
    return os.path.join(image_path, uuid)


# Init the opener function
iiif.uuid_to_image_opener_handler(uuid_to_source)

# Initialize the cache
app.config['IIIF_CACHE_HANDLER'] = redis

コード例 #10
0
ファイル: main.py プロジェクト: helderheit/Zenetti
from modules.database import database

app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = "webapp/data"
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 * 1024

api_url_prefix = "/api/1.0/"

#load api functins
app.register_blueprint(api_blueprint, url_prefix=api_url_prefix)

#load functions serving the webapp
app.register_blueprint(web_blueprint)

##IIIF API
ext = IIIF(app=app)
api = Api(app=app)
ext.init_restful(api)

#load functions serving the images
app.register_blueprint(data_blueprint)

#initialise database
database.initialize()

if __name__ == "__main__":
    port = 4000
    host = "0.0.0.0"

    app.run(port=port, host=host, debug=False, threaded=True)