Asynchronous Base Service
Serves results via API POST request.
On an OS with Docker installed.
docker-compose build
docker-compose up
python3 main.py
sudo nano /etc/systemd/system/botsApi.serviceOR
cat<<-EOF > /etc/systemd/system/botsApi.service
[Unit]
Description=botsApi daemon
After=network-online.target
[Service]
Type=simple
Restart=always
RestartSec=1
User=root
Group=root
WorkingDirectory=/root/app
ExecStart=python3 main.py
SyslogIdentifier=botsApi
StartLimitInterval=0
LimitNOFILE=65536
LimitNPROC=65536
[Install]
WantedBy=multi-user.target
EOFsudo systemctl daemon-reload
sudo chmod 755 /etc/systemd/system/botsApi.service
sudo systemctl enable botsApi.service
sudo service botsApi start
sudo service botsApi status
sudo service botsApi stop
sudo service botsApi restart
sudo apt-get install grc
sudo grc tail -f /var/log/syslogExample with Python
import requests
# define URL
url = "http://127.0.0.1:5000"
# # test request
token = "REQUEST TOKEN!!"
headers = {"token": token}
params = {
"signed_txns": [
{"owner_address": address, "tx_bytes": tx},
{"owner_address": address, "tx_bytes": tx},
]
}
# send request
response = requests.post(url, params=params)
print(f"{response.json()}\n")Curl requests can be displayed by running python3 test_api.py
To add specific headers update headers = None in test_api.py to a dictionary of headers.
Look for the following in the logs output or check the api_tests.log
[INFO]: cURL Request:
To convert CURL requests to example code for languages other than python - use https://curlconverter.com/
```curl
Start the service locally or remotely
python3 main.py
Set the url in tests/test_api.py
i.e. url = "http://127.0.0.1:5000"
Run the tests
pytest
>>> pytest
Happy Flow
[
]
Errors