Skip to content

Commit

Permalink
Update: api can search for specifc date and restaurant menu
Browse files Browse the repository at this point in the history
  • Loading branch information
lamtonylam committed Oct 13, 2024
1 parent 26bdfc5 commit 41edfb6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
[https://makkara.fly.dev](https://makkara.fly.dev)

[API](https://makkara.fly.dev/api)
### API Endpoints

#### Returns Sausage Dates

https://makkara.fly.dev/api

#### Returns Chemicum/Exactum Menu for Today

https://makkara.fly.dev/api/chemicum/exactum

#### Returns Menu for Restaurant for Specific Date
Date is in format 2024-10-30
https://makkara.fly.dev/api/datesearch/<string:restaurant_name>/<string:date>
29 changes: 28 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ def get_todays_menu(restaurant_name):
return restaurant_menu


def get_menu_for_date(restaurant_name, specific_date):
restaurant_menu = []
for object in response.json():
if object["title"].lower() == restaurant_name.lower():
for menu in object["menuData"]["menus"]:
if specific_date in menu["date"]:
data = menu["data"]
for item in data:
restaurant_menu.append(item["name"])
break

return restaurant_menu


def unicafe_global_sausagesearch():
viikkiRestaurants = [
"Tähkä",
Expand Down Expand Up @@ -176,14 +190,27 @@ class UnicafeGlobalSausageSearch(Resource):
def get(self):
return unicafe_global_sausagesearch()


class UnicafeChemicum(Resource):
def get(self):
return get_todays_menu("Chemicum")


class UnicafeExactum(Resource):
def get(self):
return get_todays_menu("Exactum")


class UnicafeDatesearch(Resource):
def get(self, restaurant_name, date):
# convert input format 2024-10-15 to 15.10.
date = datetime.strptime(date, "%Y-%m-%d").strftime("%d.%m.")
return get_menu_for_date(restaurant_name, date)


api.add_resource(UnicafeGlobalSausageSearch, "/api")
api.add_resource(UnicafeChemicum, "/api/chemicum")
api.add_resource(UnicafeExactum, "/api/exactum")
api.add_resource(UnicafeExactum, "/api/exactum")
api.add_resource(
UnicafeDatesearch, "/api/datesearch/<string:restaurant_name>/<string:date>"
)

0 comments on commit 41edfb6

Please sign in to comment.