File: first_step_3.py

package info (click to toggle)
python-hug 2.6.0-2.4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,072 kB
  • sloc: python: 8,938; sh: 99; makefile: 17
file content (14 lines) | stat: -rw-r--r-- 413 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
"""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()