Issue
I'm working on a very basic Web Application (built using flask and flask_restful) with unrelated views split into different blueprints.
Different blueprints deal with a different instance of a class.
Now I want to design a page with status(properties and value) of all the classes these blueprints are dealing with. The page is a kind of a control panel of sorts.
For this I want to call all the status routes (defined by me) in different blueprints from a single route(status page route) in a different blueprint. I have been searching for a while on how to make internal calls in Flask / Flask_restful, but haven't found anything specifically for this. So....
- I would love to find out how to make these internal calls.
- Also, is there any problem or convention against making internal calls.
- I also thought of making use of the requests calls using Requests module, but that feels more like a hack. Is this the only option I got??? If yes, is there a way I dont have to hard code the url in them like using something close to url_for() in flask??
Thanks.. :)
Solution
- I would love to find out how to make these internal calls.
Ans: use url_for() or Requests module, as u do for any other post or get method.
- Also, is there any problem or convention against making internal calls ?
Ans: I didn't find any even after intensive searching.
- I also thought of making use of the requests calls using Requests module, but that feels more like a hack. Is this the only option I got??? If yes, is there a way I don't have to hard code the url in them like using something close to url_for() in flask??
Ans: If you don't wanna use Requests module, url_for() is the simplest and cleanest option there is. Hard coded path is the only option.
Answered By - Manipal King
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.