REST app for candy delivery service.
App uses FastAPI, Uvicorn, Pydantic and Pytest libraries (reflected in requirements).
- If not installed, install git and virtualenv with commands:
sudo apt install python3-venvandsudo apt install git - Clone the repository
- Create the virtual environment for project:
python3 -m venv delivenv - Activate the environment:
source delivenv/bin/activate - Get into the directory of repo and install required libraries with
pip3 install -r requirements.txt - Run
uvicorn main:app --host 0.0.0.0 --port 8000
- Perform steps 0-4 if not performed yet.
- Run
pytest
To deploy the app as system service follow these steps:
- Get into repo directory
- Run
sudo cat service.txt >delivery.service - Do
sudo mv delivery.service /etc/systemd/system/ - Enable the service with
sudo systemctl enable delivery.service - Finally, start the service with
sudo systemctl start delivery.service
Note: If the virtualenv you created has the name that differs from "delivenv", then open delivery.service file and change the name to yours in 'Environment=...' and 'ExecStart=' paths.