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
pippackage manager
Installation¶
Clone the repository** and navigate to the project directory.
Create a virtual environment.
Install dependencies¶
Deployment¶
Run the installation script to set up dependencies and environment.
Deploy and start the service¶
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.
Execute Python code.
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.
Logs¶
For troubleshooting and logs, check the systemd journal.