Skip to content Skip to sidebar Skip to footer

Call A Route From Within Another Route In Flask

I am trying to figure out the best way to get data into my template in a flask app. I have two routes, one to display the index page, and another that just returns json. I am tryin

Solution 1:

Yes, this is the wrong approach. Generally with web frameworks it's best to think of a route as serving up the whole of a page. But that's not to say that you can't call multiple functions from within that route handler. So in your case I would recommend moving your json code into its own function, which you can call from both routes if you need to.


Post a Comment for "Call A Route From Within Another Route In Flask"