https://github.com/michaljach/python-flask-mongoengine-docker-starter
Starter for RESTful API with Python, Flask, MongoDB and Docker
https://github.com/michaljach/python-flask-mongoengine-docker-starter
api boilerplate docker docker-compose flask flask-restful flask-restplus mongoengine python rest restful
Last synced: 9 months ago
JSON representation
Starter for RESTful API with Python, Flask, MongoDB and Docker
- Host: GitHub
- URL: https://github.com/michaljach/python-flask-mongoengine-docker-starter
- Owner: michaljach
- License: mit
- Created: 2020-04-13T09:54:55.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-02-15T23:43:38.000Z (about 3 years ago)
- Last Synced: 2024-11-11T04:29:39.522Z (over 1 year ago)
- Topics: api, boilerplate, docker, docker-compose, flask, flask-restful, flask-restplus, mongoengine, python, rest, restful
- Language: Python
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# python-flask-mongoengine-docker-starter
[](https://www.python.org/)
[](https://opensource.org/licenses/MIT)
[](https://github.com/michaljach/python-flask-mongoengine-docker-starter)
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.
## Stack
- Python 3
- Flask
- Flask-RESTPlus
- Mongoengine
- Unittest
- Docker
- Swagger
## Usage
[Install Docker](https://www.docker.com/products/docker-desktop) if you don't have it yet and run the container:
```sh
$ 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`:
```sh
web:
...
environment:
- ENV=Testing
```
You can use Development, Production or Testing or add your own environment in `api/config.py`.
## Structure
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
```
## Documentation
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](https://flask-restplus.readthedocs.io/en/stable/swagger.html).

## Testing
You can run tests easily within Docker container:
```
docker-compose run web python tests/test_base.py
```
## License
See LICENSE file.