> For the complete documentation index, see [llms.txt](https://docs.mavibot.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mavibot.ai/doc/uk/specialni-mozhlivosti/programuvannya-na-python.md).

# Програмування на Python

## Як запускати вихідний код Python у Mavibot.ai

Щоб запустити вихідний код (файл із розширенням .py), використовується функція **code\_executor(URL, params)** де

**URL** - URL до вихідного коду («<https://mavibot.ai/handler.py»> як приклад)

**params** - параметри, потрібні для вашого коду (вони надходять як рядок JSON)

Повернене значення — це те, що повертає функція

Приклад:

![](https://lh5.googleusercontent.com/LS-DvyjzFkpV6FMf1xDu_lgBMle_VulqC6M2W1SIQdu_q7GzALODAfVzU4Xu41O-hk7_hRJvAxHL-GHzqWT5Gmn5WYntvr-KdmgxhBPqxxQ14l5Vs7cuPIkLEnisPcrFoCkLKiKfEky3VgOsDg)

{% hint style="success" %}
Якщо вам потрібно надсилати API-запити з російської IP-адреси, ми рекомендуємо використовувати проксі Salebot.

Приклад:

requests.get('<https://google.com>', proxies={'https': '[http://51.250.88.121:24532'}).text](https://docs.mavibot.ai/doc/uk/specialni-mozhlivosti/http:/51.250.88.121:24532'}\).text)
{% endhint %}

{% hint style="info" %}
`139.59.148.123` — виконавець коду Python
{% endhint %}

**Вимоги до вихідного коду:**

Ваш код має містити функцію handle(data), яка приймає параметр, що містить хеш параметрів, які ви вказали в налаштуваннях блоку. Функція має повертати значення, яке після виконання буде передано назад боту. Щоб розділити результат на параметри редактора, повертайте його як JSON.

Приклад коду ви можете побачити тут: <https://mavibot.ai/handler.py>

Ви можете використовувати стандартні бібліотеки, а також перелічені нижче:

requests \
logger \
gspread \
oauth2client \
numpy \
pyzbar \
fuzzywuzzy \
python-Levenshtein \
re \
urllib \
time \
json \
hmac \
hashlib \
beautifulsoup4 \
pandas \
base64 \
xmltodict \
mysql-connector-python \
zeep \
Google-api-python-client

### Відеоогляд


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mavibot.ai/doc/uk/specialni-mozhlivosti/programuvannya-na-python.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
