2020-04-10 14:14:34 +00:00
|
|
|
from flask_restful import Resource, reqparse
|
|
|
|
|
import flask
|
|
|
|
|
import requests
|
|
|
|
|
import application.config as config
|
|
|
|
|
import json
|
|
|
|
|
import base64
|
|
|
|
|
from application.db import Session, Recipe, Ingredient
|
2020-04-17 20:29:50 +00:00
|
|
|
import search
|
|
|
|
|
import migrate
|
2020-04-10 14:14:34 +00:00
|
|
|
|
2020-04-17 20:29:50 +00:00
|
|
|
class RecipeList(Resource):
|
2020-04-10 14:14:34 +00:00
|
|
|
def get(self):
|
|
|
|
|
""" """
|
2020-04-17 20:29:50 +00:00
|
|
|
|
|
|
|
|
parser = reqparse.RequestParser()
|
|
|
|
|
parser.add_argument('ingred', type=str, action='append')
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
ingreds = args["ingred"]
|
|
|
|
|
ingreds = [migrate.stemWord(ingred)[0] for ingred in ingreds + search.defaultArr]
|
2020-04-10 14:14:34 +00:00
|
|
|
|
2020-04-17 20:29:50 +00:00
|
|
|
indx = search.fastes(ingreds )
|
|
|
|
|
recs = search.getRecDict(indx, ingreds )
|
|
|
|
|
|
|
|
|
|
#print(recs)
|
|
|
|
|
|
|
|
|
|
return flask.make_response(flask.jsonify({'data': recs}), 200)
|
2020-04-10 14:14:34 +00:00
|
|
|
|
|
|
|
|
|