This is a starter or boilerplate to create RESTful API with Python and MongoDB using Flask microframework. The project uses Docker (docker-compose) for easy to use, encapsulated and safe environment.
- Python 3
- Flask
- Flask-RESTPlus
- Mongoengine
- Unittest
- Docker
- Swagger
Install Docker if you don't have it yet and run the container:
$ docker-compose up
It will run both Web and Mongodb containers in Development environment on localhost:5100
.
For other environments change ENV in docker-compose.yml
:
web:
...
environment:
- ENV=Testing
You can use Development, Production or Testing or add your own environment in api/config.py
.
Here is a folder and file structure with explanation.
├── Dockerfile
├── LICENSE
├── README.md
├── api
│ ├── app.py - Entry point of application
│ ├── config.py - Configuration with environments
│ └── v1 - API version 1
│ ├── database
│ │ └── models.py - All data models app uses
│ └── resources
│ ├── routes.py - List of namespaces for routing
│ └── todos.py - Example Todo resource
├── docker-compose.yml
├── requirements.txt - Dependencies
└── tests
└── text_base.py - Example test file
Thanks to handy decorators this boilerplate will generate Swagger with documentation on the fly.
By default Swagger runs on /
so you should see it on http://localhost:5100
. Read more here.
You can run tests easily within Docker container:
docker-compose run web python tests/test_base.py
See LICENSE file.