diff --git a/reciperadar/__init__.py b/reciperadar/__init__.py index 58318a0..d65eb9a 100644 --- a/reciperadar/__init__.py +++ b/reciperadar/__init__.py @@ -33,4 +33,3 @@ import reciperadar.api.recipes import reciperadar.api.redirect import reciperadar.api.search -import reciperadar.api.view diff --git a/reciperadar/api/recipes.py b/reciperadar/api/recipes.py index f4eeac0..50c2f55 100644 --- a/reciperadar/api/recipes.py +++ b/reciperadar/api/recipes.py @@ -5,7 +5,6 @@ from reciperadar.models.events.search import SearchEvent from reciperadar.models.recipes import Recipe from reciperadar.search.recipes import RecipeSearch -from reciperadar.services.database import Database from reciperadar.utils.decorators import internal from reciperadar.workers.events import store_event from reciperadar.workers.recipes import crawl_url, index_recipe @@ -15,20 +14,27 @@ @app.route('/api/recipes/') @internal def recipe_get(recipe_id): - session = Database().get_session() - recipe = session.query(Recipe).get(recipe_id) + recipe = Recipe().get_by_id(recipe_id) if not recipe: - session.close() return abort(404) + return jsonify(recipe.to_doc()) - response = recipe.to_doc() - session.close() - return jsonify(response) +@app.route('/api/recipes//view') +def recipe_view(recipe_id): + recipe = Recipe().get_by_id(recipe_id) + if not recipe: + return abort(404) + + results = { + 'total': 1, + 'results': [recipe.to_dict()], + } + return jsonify(results) @app.route('/api/recipes/search') -def recipes(): +def recipe_search(): include = request.args.getlist('include[]') exclude = request.args.getlist('exclude[]') equipment = request.args.getlist('equipment[]') diff --git a/reciperadar/api/view.py b/reciperadar/api/view.py deleted file mode 100644 index 44ac5ca..0000000 --- a/reciperadar/api/view.py +++ /dev/null @@ -1,17 +0,0 @@ -from flask import abort, jsonify - -from reciperadar import app -from reciperadar.models.recipes import Recipe - - -@app.route('/api/recipes//view') -def recipe(recipe_id): - recipe = Recipe().get_by_id(recipe_id) - if not recipe: - return abort(404) - - results = { - 'total': 1, - 'results': [recipe.to_dict()], - } - return jsonify(results)