'Show nutrients' button not working
Geeky-Sam01 opened this issue · comments
Hey , I uploaded an image. It shows me this :
There may be some issue with the post request in file app.py at line 124.
dict_food = requests.post(url, files={"img": buffer.getvalue()}).json()
I think the response returns an error message or HTML,
for example - {400:"bad request"}
or it might not be valid JSON, leading to a JSONDecodeError. You can handle error responses or check if the response is json or not.
Hi Sam
This app was developed around 1 year ago. So it might be possible that the nutrition data fetched from this website https://fdc.nal.usda.gov/index.html has changed the format, or the way it shall be fetch.
So these are the steps to check:
-
Check locally if these data from the app can be fetched. Here is the code
https://github.com/benitomartin/foodscore-code/blob/master/foodscore/data/datasearch.py -
Otherwise check the website above and go the the API to understand how to get them and correct the code
-
Push a new dockerfile to GCP to get the URL. Add that url to line 96 here https://github.com/benitomartin/foodscore-app/blob/master/app.py
These are the steps to follow. Unfortunatelly I am not maintaining this app as it was developed as part of a course and it is only for showcasing and educational purposes.
If you have further questions let me know!