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!

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 False

If 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:


Get tomorrow's app in your inbox

Don't miss a day! We'll mail you a new web app every morning until Christmas Day: