This project was created with Python and FastAPI framework.
- Please check out FastAPI documentation: https://fastapi.tiangolo.com/
Please set up your Python version to 3.10
python3 --version
Create your .env
file.
cd <project-directory>
$ touch .env
APP_NAME=Example
APP_VERSION=1.0.1
ENV=local
APP_PORT=3002
APP_HOST=localhost
BODY_LIMIT=12000
LOG_LEVEL=info
SWAGGER_ENABLED=true
DEBUG=true
MICROSERVICE_CLIENT_TIMEOUT=60
RABBITMQ_HOST=localhost
RABBITMQ_PORT=5672
RABBITMQ_USERNAME=guest
RABBITMQ_PASSWORD=guest
RABBITMQ_EXCHANGE_NAME=message_exchange
RABBITMQ_EXCHANGE_TYPE=fanout
RABBITMQ_QUEUE=message_queue
RABBITMQ_ROUTING_KEY=0
RABBITMQ_CONNECTION_ATTEMPTS=0
RABBITMQ_RETRY_DELAY=0
- Install virtual environment
$ pip install virtualenv
- Created virtual environment
$ virtualenv env
- Activate the virtual environment
$ source env/bin/activate
- Install libraries
$ pip install -r requirements.txt
$ python3 main.py
- Open browser and direct to http://127.0.0.1:3000/docs or http://127.0.0.1:3000/redoc
- Setup RabbitMQ
$ brew update
$ brew install rabbitmq
$ brew info rabbitmq
- Configration RabbitMQ
CONF_ENV_FILE="/opt/homebrew/etc/rabbitmq/rabbitmq-env.conf" /opt/homebrew/opt/rabbitmq/sbin/rabbitmq-server
- RabbitMQ service start & stop
$ brew services start rabbitmq
&&
$ brew services stop rabbitmq
Don't forget to enable virtual environment
$ cd producer
$ python3 app.py