Flask patterns -- application factory, blueprints, error handlers, extensions, request lifecycle, configuration, logging, CLI commands
98
98%
Does it follow best practices?
Impact
98%
1.28xAverage score across 5 eval scenarios
Passed
No known issues
A cooking enthusiast community wants a Flask API for sharing recipes. Users can create recipes with ingredients and steps, browse recipes by category, and rate them.
Data model:
Endpoints needed:
POST /api/recipes -- create a recipe (with nested ingredients and steps in the request body)GET /api/recipes -- list recipes with optional ?category=dessert filterGET /api/recipes/<id> -- get a recipe with its ingredients, steps, and average ratingPOST /api/recipes/<id>/ratings -- add a rating to a recipeDELETE /api/recipes/<id> -- delete a recipe and its related dataRequirements:
flask seed-recipes that populates sample data for development.Produce Python source files in a recipe-api/ directory:
app/__init__.py -- application factory with CLI command registrationapp/extensions.py -- extension instancesapp/errors.py -- custom exceptions and error handlersapp/db.py -- data storeapp/routes/recipes.py -- recipes blueprintapp/routes/ratings.py -- ratings blueprinttests/conftest.py -- test fixturesrun.py -- entry pointrequirements.txtDo not run pip install or start the server.