Skip to content

Instantly share code, notes, and snippets.

@timothycrosley
Created March 18, 2016 07:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timothycrosley/3bbcd159be2fe00caf1c to your computer and use it in GitHub Desktop.
Save timothycrosley/3bbcd159be2fe00caf1c to your computer and use it in GitHub Desktop.
Chainable Routing
import hug
api = hug.get(on_invalid=hug.redirect.not_found)
@api.urls('/do-math', examples='number_1=1&number_2=2')
def math(number_1: hug.types.number, number_2: hug.types.number):
return number_1 + number_2
@api
def happy_birthday(name, age: hug.types.number):
"""Says happy birthday to a user"""
return "Happy {age} Birthday {name}!".format(**locals())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment