How to use api.add_resource to route in different files?

I have a routing table in using flask-restful like:

api.add_resource(sonarqube.SonarqubeHistory, '/sonarqube/<project_name>')
api.add_resource(project.ProjectFile, '/project/<sint:project_id>/file')
api.add_resource(redmine.RedmineFile, '/download', '/file/<int:file_id>')

The resource classes are in other modules like,, or

My question is: Is that possible to also move api.add_resource() into the other modules (For more structured code)? I tried simply move the statement and from apis import api, but since also do other works it will result circular import.

Is there an example for similar use cases?

Read more here:

Content Attribution

This content was originally published by Romulus Urakagi Ts'ai at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: