Usage Examples
Here are some further usage examples for the library.
Websockets quickstart example
The full quickstart example for Websockets (also shown here).
"""Websocket/API example
This example shows you the "standard" way of getting the week
menu, which will return a parsed list of Day objects.
NOTE: Want to do this with less code?
Check the compact example."""
from eatery_nod import EateryNod #Import the library
menu = EateryNod.Menu() #Create a menu object
menu.initialize() #Initialize (this is only required when using WebSockets)
print("Retrieving menu...") #Print out the status
week_menu = menu.get_menu() #Get the menu
for day in week_menu: #Loop through all the days in the menu
menu_items_str = "\n".join(day.menu_items) #Format the menu items to a pretty string as they are returned as a list
print(day.day_name_sv) #Print out the day name (in Swedish)
print(menu_items_str) #Print out the menu items
print("Day information:") #Print out a nice divider
print("Date: " + str(day.day_date)) #Print out the day date
print("Dessert served?: " + str(day.dessert_served)) #Print out if dessert is served (this will print either True or False)
print("Pancakes served?: " + str(day.pancakes_served)) #Print out if pancakes are served (this will print either True or False)
print("Hamburgers served?: " + str(day.burgers_served)) #Print out if hamburgers are served (this will print either True or False)
print("---------------------------------------------------") #Print out a divider line
last_retrieved = menu.last_retrieved["json"] #Get when the menu was last retrieved
print("Menu retrieved: " + str(last_retrieved)) #Print out when the menu was last retrieved.Websockets quickstart compact example
A more compact version of the code above.
Images quick example
A quick usage example for using the library to retrieve and save an image of the current week menu image. This does not require or use the Websocket interface.
Last updated
Was this helpful?