Write a function app
How to use @define_app on a plain function, specifying input/output type hints and turning function parameters into constructor arguments.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
- We specify the
app_typeexplicitly here. - We assign the citation in the class definition.
- The function definition has type hints for its first argument and its return type.
Note
Your function can only have one required argument. It can have any number of optional arguments.
Pay attention to the order of arguments for the function! Every call to the app provides a new instance of val. Whereas str.upper is assigned to the variable convert. You can think of all of the other arguments as being arguments to a class constructor. Under the hood, scinexus caches these and injects them into each call of your function with new values of val.