This documentation outlines the endpoints available in the example REST API built with flask and python. GIT
More details here
Resource | Documentation |
---|---|
python | https://www.python.org/ |
pytest | https://docs.pytest.org/en/8.0.x/ |
pytest-html | https://docs.pytest.org/en/8.0.x/ |
flask | https://flask.palletsprojects.com/en/3.0.x/ |
flask-restx | https://flask-restx.readthedocs.io/en/latest/ |
flask-SQLAlchemy | https://flask-sqlalchemy.palletsprojects.com/en/3.1.x/ |
Swagger | https://swagger.io/ |
pyyaml | https://pypi.org/project/PyYAML/ |
python-dotenv | https://pypi.org/project/python-dotenv/ |
The project structure is organized as follows:
├── app/
│ ├── api/
│ │ ├── controller/
│ │ ├── exception/
│ │ ├── model/
│ │ ├── repository/
│ │ ├── service/
│ │ └── util/
│ ├── resources/
│ └── test/
│
├── ci/
│ ├── deploy/
│ ├── docker/
│ └── kubernates/
│
├── README.md
├── requirements.txt
├── .flaskenv
└── .gitignore
The base URL for all endpoints is http://localhost:5000/v1/user
.
The following endpoints are available:
- POST
/v1/users
: create user.
curl --location 'http://localhost:5000/v1/user' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Charles",
"email": "[email protected]"
}'
- GET
/v1/users
: Get all users.
curl --location 'http://localhost:5000/v1/users'
- GET
/v1/user/123
: Get a user by ID.
curl --location 'http://localhost:5000/v1/user?id=4'
- PUT
/v1/user
: Update a user by ID.
curl --location --request PUT 'http://localhost:5000/v1/user?id=3' \
--header 'Content-Type: application/json' \
--data-raw '{
"id": 3,
"name": "Mike",
"email": "[email protected]"
}'
- DELETE
/v1/user/123
: Delete a user by ID.
curl --location --request DELETE 'http://localhost:5000/v1/user?id=4'
The openApi URL documentation in local environment is http://localhost:5000/api-doc.html
.
- Step 1:
python -m venv env
- Step 2:
source env/bin/activate
- Step 3:
pip install -r requirements.txt
- Step 4:
pip install -e .
Report URL
pytest
flask run
This Api is distributed under the terms of the MIT License. See the license for details.