Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Create a new variable named api in each of the resources that's an Api instance for the Blueprint. Then add both of the
Create a new variable named api in each of the resources that's an Api instance for the Blueprint. Then add both of the Resources to api. You can use whatever endpoint name you want, but make sure the URL pattern is like "/api/v1/[PLURAL RESOURCE]". Remember to include the id argument in the appropriate URLs.
from flask import Flask from resource.ingredients import ingredients_api from resource.recipes import recipes_api app = Flask(__name__) app.register_blueprint(recipes_api) app.register_blueprint(ingredients_api) if __name__ == '__main__': app.run()
api.add_ingredients( IngredientsList, '/api/v1/ingredients', endpoint='ingredients' ) api.add_resource( Ingredients, '/api/v1/ingredients/<int:id>', endpoint='ingredient' )
api.add_resource( RecipeList, '/api/v1/recipes', endpoint='recipes' ) api.add_resource( Recipe, '/api/v1/recipes/<int:id>', endpoint='recipe' )