> For the complete documentation index, see [llms.txt](https://backbench.gitbook.io/backbench-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://backbench.gitbook.io/backbench-docs/getting-started/python.md).

# Python

Supports: **python3.7**

## Function declaration

{% code title="hello.py" %}

```python
def endpoint(req):
    return "Hello World"
```

{% endcode %}

**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.

{% code title="hello.py" %}

```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))
```

{% endcode %}
