This server was generated by the swagger-codegen project from OpenAPI Spec v3.
This example uses the Connexion library on top of Flask.
Python 3.5.2+ is required. The below example commands assume that python
and pip
execute Python 3 on your system. You may need to specify python3
if it is not already the default.
On MacOS, XCode command line tools are required to run MongoDB locally. Install them if you haven't already.
xcode-select --install
You will also need to have MongoDB installed.
brew tap mongodb/brew
brew install mongodb-community
Clone this repo and navigate to the python-flask-server-generated
directory.
Install required Python packages.
pip install -r requirements.txt
Start the local MongoDB server.
brew services start mongodb-community@5.0
Set localhost
as the Mongo server in an environment variable. This set
command is an example of how to do this on fish, your shell's syntax may be slightly different.
set -Ux MONGOSERVER "mongodb://localhost:27017"
Run the server.
python -m swagger_server
Swagger UI should be running on http://localhost:8080/ui/
This is an example of how to create a trainer via curl
.
curl --location --request POST 'localhost:8080/trainer' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "keilly@campgladiator.com",
"first_name": "Keilly",
"last_name": "Cutler",
"phone": 5085969529
}'
This is an example of how to retrieve a trainer record, where the string 610b3eb79e20abaacdc11e8d
is the ID returned by the POST
method.
curl --location --request GET 'localhost:8080/trainer/610b3eb79e20abaacdc11e8d'
To run the server on a Docker container, please execute the following from the python-flask-server-generated
directory:
docker build -t swagger_server .
docker run -p 8080:8080 -e MONGOSERVER='mongodb://host.docker.internal:27017' swagger_server
- Implement a method to get trainer by name or email.
- Fix the way ID is handled, right now I'm sort of awkwardly returning the MongoDB ObjectID.
- Deploy a production MongoDB cluster in a cloud.
- Set up CI/CD and deploy this server image on a K8s or serverless cloud service.
- Provide an option to connect to cloud based MongoDB from local OS for development purposes.
- Write better tests.
- Add Linux specific instructions to this document.
- Create a replicated failover DB.
- Implement a message queue.
- Add caching and WAF in front of the API.
- Deploy a second region with GLB for availability.