This is a simple JSON Server implemented in Python using Flask to serve as a fake API. It allows you to create, read, update, and delete resources, with data stored in a JSON file. It's inspired by Node JSON-Server, but implemented in Python.
- Supports multiple resource endpoints.
- Performs basic CRUD operations (Create, Read, Update, Delete).
- Stores data in a JSON file.
- Easy setup and usage.
-
Clone this repository or download the source code.
-
Install the required Python packages using pip:
pip install -r requirements.txt
-
Create a db.json file with your sample data. Example data structure:
{
"posts": [
{ "id": 1, "title": "json-server", "author": "typicode" }
],
"comments": [
{ "id": 1, "body": "some comment", "postId": 1 }
],
"profile": { "name": "typicode" }
}
- Run the server:
python server.py
Your server will be running at http://localhost:<PORT>
where is the port specified in your .env file.
-
Access your data using HTTP requests. Example:
- GET: http://localhost:/posts
- POST: http://localhost:/posts (with a JSON payload)
- PUT: http://localhost:/posts/1 (with a JSON payload)
- PATCH: http://localhost:/posts/1 (with a JSON payload)
- DELETE: http://localhost:/posts/1
This section outlines the upcoming features and improvements planned for this project. Feel free to contribute, suggest ideas, or work on any of these tasks. Check the boxes as items are completed.
-
Finding Records by Specific Field Value: Implement the ability to find records by a specific field value.
-
Limit and Skip: Add support for limiting and skipping records for paginated results.
-
Sorting: Enable the sorting of records based on specific fields.
-
Group By: Implement grouping of records based on a particular field.
If you're interested in working on any of the above tasks or have your ideas to add to the roadmap, please follow these steps:
- Fork the repository.
- Create a new branch for your work:
git checkout -b feature/your-feature-name
. - Implement your changes.
- Test thoroughly and ensure that the code meets our coding standards.
- Submit a pull request for review.