Skip to content

PyServe installation

This guide provides instructions for system administrators to install, configure, deploy, and manage the PyServe backend service.

Overview

PyServe is a lightweight Python backend for code execution and formatting, designed for integration with other services.

Requirements

  • Python version 3.10 or newer
  • pip package manager

Installation

Clone the repository** and navigate to the project directory.

git clone https://bitbucket.org/baosystems/pyserve

Create a virtual environment.

python -m venv venv
source venv/bin/activate

Install dependencies

pip install -r requirements.txt

Deployment

Run the installation script to set up dependencies and environment.

sh div/script/install.sh

Deploy and start the service

sh div/script/deploy.sh

Systemd

Copy the file at div/conf/pyserve.service to /etc/systemd/system/ and enable the service.

sudo cp div/conf/pyserve.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable pyserve
sudo systemctl start pyserve

API endpoints

Format Python code.

POST /pyserve/format

Execute Python code.

POST /pyserve/execute

Example API request

Format code.

curl -X POST http://localhost:8000/pyserve/format \
-H "Content-Type: application/json" \
-d '{"code": " print (\"hello world\") "}'

nginx (optional)

Configure Nginx as a reverse proxy for PyServe. Example configuration is provided in the repository.

div/conf/nginx.conf

Logs

For troubleshooting and logs, check the systemd journal.

sudo journalctl -u pyserve
tail -f /var/log/pyserve.log
tail -f /var/log/pyserve.err