Follow these steps to set up and start the FastAPI project using a virtual environment (venv).
- Python 3.7+
- Git
-
Clone the Repository
git clone https://github.com/dev-dojo-uok/iot-manager.git core cd core -
Create a Virtual Environment
python -m venv .venv
-
Activate the Virtual Environment
-
On Windows:
.venv\Scripts\activate
-
On macOS/Linux:
source .venv/bin/activate
-
-
Install Dependencies
pip install -r requirements.txt
-
Run the FastAPI Application
uvicorn app.main:app --reload
Replace
main:appwith the appropriate module and application instance if different. -
Access the Application
Open your browser and navigate to
http://127.0.0.1:8000to see the FastAPI application running. -
API Documentation
- Swagger UI:
http://127.0.0.1:8000/docs - ReDoc:
http://127.0.0.1:8000/redoc
- Swagger UI:
-
Build the Docker Image
docker build -t iot-manager . -
Run the Docker Container
docker run -d --env-file .env --network host iot-manager
This maps the container's port
8000to the host's port8000, allowing you to access the application athttp://127.0.0.1:8000.
When you're done, you can deactivate the virtual environment with:
deactivate- Ensure you have the correct permissions to install packages and run scripts.
- Update the
requirements.txtfile as needed to include all necessary dependencies.