It’s Boxing Day, we’re stuffed with turkey and wondering what to do with all those leftovers. What’s left to do except watch some festive TV and grab a final mince pie or two?
Hang on. Rustling through the empty sweet-wrappers of our Anvil Advent Calendar, it seems that we have one final app to share with you after all!
π The Twelve Emoji of Christmas
As you know, the twelve days of Christmas actually start on Christmas Day itself and continue into January - a traditional time of merriment and gifting that inspired the old carol.
Since we already have a fun app for sending emoji to people I figured why not adapt it for a final festive treat?
https://twelve-emoji-of-christmas.anvil.app 
 
 How the app will look on the twelth day!
Python’s built in datetime module lets us work out if it’s one of the twelve days of Christmas.
@anvil.server.callable
def is_xmas_season():
  """
  Let's find out if it's one of the twelve days of Christmas
  """
  today = date.today()  # Find out today's date
  beginning = date(2020, 12, 25)
  diff = today - beginning
  
  if diff.days < 13 and diff.days >= 0:
    return diff.days + 1
  
  return FalseIf so, we check which emoji gifts to display under our tree - which is easy given Python3’s native support for Unicode strings!
@anvil.server.callable
def get_emoji_for_day(n_xmas):
  """ Return the right gift emojis for the day of Christmas that you want """
  xmas_moji = {
              1: 'π¦π³',
              2: 'ππ',
              3: 'πππ',
              4: 'π¦π¦π¦π¦',
              5: 'πππππ',
              6: 'ππππππ',
              7: 'π¦’π¦’π¦’π¦’π¦’π¦’π¦’',
              8: 'π©βπΎπ©βπΎπ©βπΎπ©βπΎπ©βπΎπ©βπΎπ©βπΎπ©βπΎ',
              9: 'πππππππππ',
              10: 'ππππππππππ',
              11: 'π·π·π·π·π·π·π·π·π·π·π·',
              12: 'π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯π₯'}
  
  moji = [xmas_moji[n] for n in range(1, n_xmas)]
  return '\n'.join(moji)The final touch: using Anvil’s Email Service and User Service I created a simple subscription flow that allows users to sign up for daily festive updates with the right emoji gifts in their inbox.
Unsubscription is easy, using a custom token generated for each user to keep things secure, just like the Fruitmoji app.
Play with it yourself
Anvil makes it easy to build knock together a front-end with email capability. To check out the source code for this app in more detail, you can clone it using the link below:
Unwrap the others while you still can:
Share the calendar:
Give the Gift of Python
Share the Advent Calendar:
 By
              
            
            By