The SDK comes with a few examples that shows the most basic usage. The examples code can be found under src/examples/ and can be ran using the make command for easy auto-completion.
Run make help for more info.
Lastly, have the cwd be the project's root folder for everything to work smoothly (but you can still run it from the app.py's base directory, don't worry).
This example project shows how to use the SDK to create the minimal Flask application, implementing the official examples for a minimal app and rendering templates.
hello_flask
│ app.py -> All of the app's source code
| sdk -> Soft link to ../../sdk/
│
└───templates
│ │ hello.html -> Taken from Flaks's quickstart page
- Clone the full sdk repository.
- Change dir into the sdk root folder.
- Run
make hello_flask(Notice: auto-completion works here...).
If all done correctly, you should see something like this:
(.venv) username@ [~/PyBackendBoilerplate/sdk]:
$ make hello_flask
<virtual environment installation log>
./run_example.sh hello_flask
Running src/examples/hello_flask/app.py
* Serving Flask app "Hello Flask" (lazy loading)
* Environment: DEVELOPMENT
* Debug mode: off
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
And then the following routes should work locally, as defined in src/examples/hello_flask/app.py:
This example project shows how to use the SDK to create a Connexion app. This examples uses OpenAPI 3 (in junction with prance to split the YAML files), and implements two RESTful APIs (routes), one that is implemented in the example app itself and one that uses a predefined route implementation from the SDK itself.
hello_connexion
│ app.py -> App's entry code (main)
| sdk -> Soft link to ../../sdk/
│
└───api -> All routes RESTful APIs implementation
│ │ root.py -> Implements the root path's RESTful API
│
└───openapi -> Root folder for the OpenAPI specification YAML files
│ openapi.yaml -> Main (root) OpenAPI specification YAML file
│ │
│ └───paths -> YAML files for specific RESTful APIs (routes) definitions
│ │ ping.yaml -> Definition for the /ping RESTful API, implementing using the SDK's predefined API implementation
- Clone the full sdk repository.
- Change dir into the sdk root folder.
- Run
make hello_connexion(Notice: auto-completion works here...).
If all done correctly, you should see something like this:
(.venv) username@ [~/PyBackendBoilerplate/sdk]:
$ make hello_connexion
<virtual environment installation log>
./run_example.sh hello_connexion
Running src/examples/hello_connexion/app.py
* Serving Flask app "Hello Connexion" (lazy loading)
* Environment: DEVELOPMENT
* Debug mode: off
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
And then the following routes should work locally, as defined in src/examples/hello_connexion/openapi/openapi.yaml:
In addition, the SDK configures connexion to automatically generate a Swagger UI route, like this (which should show both of the above RESTful APIs (routes)):