Skip to content

Instantly share code, notes, and snippets.

@timothycrosley
Last active March 15, 2016 01:37
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/2383721288b0ca26bdb2 to your computer and use it in GitHub Desktop.
Save timothycrosley/2383721288b0ca26bdb2 to your computer and use it in GitHub Desktop.
Adding CLI access to our service
"""First hug API (local, command-line, and HTTP access)"""
import hug
@hug.cli()
@hug.get(examples='name=Timothy&age=26')
@hug.local()
def happy_birthday(name: hug.types.text, age: hug.types.number, hug_timer=3):
"""Says happy birthday to a user"""
return {'message': 'Happy {0} Birthday {1}!'.format(age, name),
'took': float(hug_timer)}
if __name__ == '__main__':
happy_birthday.interface.cli()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment