Skip to content

Serve multiple instances with different data domains #5

Open
@amotl

Description

@amotl

Hi there,

while I recognized that @linar-jether planned to bring Flask Blueprints [1] into the mix, I am aiming at serving multiple data domains from a single Python Flask app. That would mean that we should not have the dictionaries to register the data generator functions on the global (module) scope.

metric_finders = {}
metric_readers = {}
annotation_readers = {}
panel_readers = {}

I wanted to reuse the service routines providing the /search, /query, /annotations and /panels endpoints within a dedicated component which can be instantiated multiple times on different URL prefixes like /domain-1/search, /domain-1/query and so forth, like @cbsmith states it at pallets/flask#612 (comment):

I am trying to have the same blueprint registered with multiple prefixes [...]

First, I tried to use Flask-Classful [2] for that job but failed. With that extension, route handlers can be defined on a class level but still the servicing is also provided on the class level and not on an object instance level.

Also, it is apparently not possible by using Flask Blueprints as we also can't make those components obtain different data to operate on. The whole discussion at pallets/flask#612 very much demonstrates this issue.

So, we might think about swapping out Flask and using Pyramid or FastAPI as a web framework in the long run. However, an alternative could be Flask Application Dispatching [3].

With kind regards,
Andreas.

[1] https://flask.palletsprojects.com/en/1.1.x/blueprints/
[2] https://github.com/teracyhq/flask-classful
[3] https://flask.palletsprojects.com/en/1.1.x/patterns/appdispatch/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions