← Скрипты и библиотеки
xNewz/samp-api
Small API project using Flask for reading SA-MP server info and sending RCON commands via UDP
Инструмент★ 0обновлён сент. 2025 г.MITPython
Открыть на GitHubREADME.md
SA-MP Query/RCON API (Flask)
Small API project using Flask for reading SA-MP server info and sending RCON commands via UDP
Installation and Running
- Create a virtualenv (recommended)
python3 -m venv .venv
source .venv/bin/activate # macOS/Linux or Windows: .venv\\Scripts\\activate
- Install dependencies
pip install -r requirements.txt
- Run in debug mode
python samp.py
# Will run at http://127.0.0.1:5000
- Run in production (example with gunicorn)
gunicorn -w 2 -b 0.0.0.0:8000 samp:app
Endpoints
- POST
/server/info- Request server info (hostname, gamemode, players, etc.)
- Example
curl -X POST http://127.0.0.1:5000/server/info \
-H "Content-Type: application/json" \
-d '{
"host": "127.0.0.1",
"port": 7777
}'
- POST
/server/rcon- Send RCON command to server (requires password)
- Example
curl -X POST http://127.0.0.1:5000/server/rcon \
-H "Content-Type: application/json" \
-d '{
"host": "127.0.0.1",
"port": 7777,
"password": "your_rcon_password",
"command": "echo hello"
}'
Important Files
samp.py: Main Flask API coderequirements.txt: List of required packages.gitignore: List of files/folders to exclude from Git
Notes
- This code sends/receives data via UDP directly to the SA-MP server. Please check your firewall and connection settings.
- For production, it is recommended to run behind a WSGI server (such as
gunicorn) and place it behind a reverse proxy (such as Nginx)
multiplayersa-mpsa-mp-developmentsa-mp-server
Страница собрана из того, что GitHub публикует о репозитории. samp.directory не хранит этот код. Сообщить о проблеме с этой записью