Build a simple REST API capable of CRUD operations on a resource, say, a "person". The chosen programming language should interface with any chosen database of your choice.
Implemented the requirements. Tested the API exhaustively using Postman and also wrote Python scripts that test the API endpoints locally as specified. View the test script at app.test_main.py
- FastApi
- Postgres database
- SqlAlchemy
- Render (deployment)
- Python == 3.10.10 installed on your system.
- PostgreSQL installed and running on your system.
-
Clone the GitHub Repository:
bash
git clone https://github.com/chimaobi-okite/HNG_TASK_2.git cd HNG_TASK_2
-
Set up a Virtual Environment:
bash
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install Dependencies:
bash
pip install -r requirements.txt
-
Configure PostgreSQL:
Start PostgreSQL and create a new database for your project.
- Create a .env file in the project root directory
- Update your project's database connection configuration in a .env file. Check the app.config file for the required configurations
Also create a test_database and modify the SQLALCHEMY_DATABASE_URL @ app.test_main.py file with your database info
-
Run Tests:
bash
pytest
-
Start the FastAPI Application:
bash
uvicorn app.main:app --reload
-
Access the API:
Open your browser and navigate to http://localhost:8000/. You should see the FastAPI default page. You can also access the auto-generated docs by visiting http://localhost:8000/docs.
-
Access the API on Web Open your browser and navigate to https://hng-task-2-i3l2.onrender.com/docs to view swagger docs for redoc nagivate to https://hng-task-2-i3l2.onrender.com/redoc