Python
Supports: python3.7
Function declaration
def endpoint(req):
return "Hello World"Public function should be named as endpoint within a module.
Argument req is a map, and has following properties:
{
"method": "",
"path": "",
"body": {},
"headers": {},
"query": {}
}NOTE: Always return string. For RUNTIME ERRORS check dashboard.
Restrictions
Module name cannot be
func.py.
Example
This is an example for couting no of times API has been accessed. For utils.py, see API Reference of python.
from utils.py import get, set, log
#for utils.py look at API reference- Python
def endpoint(req):
count = get("count")
if count==None:
count = 0
else:
count = str(count)
count = count + 1
set("count", str(count))
log("visit count of the API is "+str(count))Last updated