Tested on Windows 10
with Python 3.10.4
. If any error occurs, download and run the project in this version.
git clone https://github.com/yoggys/flask-rest-api
cd flask-rest-api
pip install -r requirements.txt
python run.py
By default server run as 127.0.0.1:5000
in production mode
.
usage: run.py [-h] [--host HOST] [--port PORT] [--dev]
options:
-h, --help show this help message and exit
--host HOST Host name
--port PORT Port number
--dev Run server in development mode
python run.py --dev --host localhost --port 8080
# Run server, wait for 3 seconds to make sure server started and run tests
python run.py --dev & sleep 3 && pytest
================================================== test session starts ===================================================
platform win32 -- Python 3.10.11, pytest-7.3.1, pluggy-1.0.0
rootdir: ...\flask-rest-api\tests
plugins: asyncio-0.21.0
asyncio: mode=strict
collected 7 items
tests.py ....... [100%]
=================================================== 7 passed in 2.19s ====================================================
├── flask-rest-api
│ ├── core
│ │ ├── __init__.py
│ │ ├── setup.py
│ │ └── utils.py
│ ├── models
│ │ └── UserModel.py
│ ├── routes
│ │ └── UserRoute.py
│ ├── tests
│ │ └── tests.py
└── └── run.py
Methods: GET
, POST
, DELETE
api/v1/users/ - Users list
Methods: GET
, POST
, PUT
, PATCH
, DELETE
api/v1/users/\<int:user_id\> - User by id