This is the back end (API) for the CreativityCrop project. Created with FastAPI, served by uvicorn and proxied by nginx.
This python project requires the following pieces of software:
- Python 3.9
- Docker (only for deployment)
- MySQL compatible database with a table from the provided
schema.sql
- Redis (optional - for cache)
Clone the project or download an archive.
git clone https://github.com/CreativityCrop/react-front-end.git
Create a virtual environment for the python project and activate it
python -m venv venv && source venv/bin/activate
Then install all the required dependencies
pip install -r requirements.txt
# runs in development environment
python main.py [dev](This is optional argument to enable reloading of files)
# for production, you need to run docker and build a container
docker build -t creativitycrop-api ./
# then run the container
docker run -itd --name container-name --net host -p 8000:8000 creativitycrop-api
# executes automated tests
pytest
You need to create a config.py
file in app/
directory. You should use the provided config.py.example
file and just fill it.
The built container can be run on any machine with docker.
For the proper operation of the whole platform a database cleaning worker is required. It consists of a simple file that should be run in regular periods by a cron job. You can use the following example code
Execute this command to edit your cron file crontab -e
, and append this line at the end
*/5 * * * * cd /home/ubuntu/python-fastapi-back-end && source venv/bin/activate && python app/worker.py && deactivate