# template-python-flask **Repository Path**: mirrors_ibm/template-python-flask ## Basic Information - **Project Name**: template-python-flask - **Description**: StarterKit for Python using Flask framework - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-07-09 - **Last Updated**: 2025-08-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README

IBM Cloud

IBM Cloud platform Apache 2

# Python/Flask Code Pattern This is a template repository for a Flask-based Python micro-service for exposing APIs. This app contains an opinionated set of components for modern development, including: - [Flask](https://flask.palletsprojects.com/) ## Deploying After you have created a new git repo from this git template, remember to rename the project. Edit `public/swagger.yaml` and `public/index.html` and change the default name to the name you used to create the template. Make sure you are logged into the IBM Cloud using the IBM Cloud CLI and have access to you development cluster. If you are using OpenShift make sure you have logged into OpenShift CLI on the command line. ```$bash npm install --location=global @ibmgaragecloud/cloud-native-toolkit-cli ``` Ensure you have the [Cloud-Native Toolkit](https://cloudnativetoolkit.dev) installed in your cluster to make this method of pipeline registry quick and easy Cloud-Native Toolkit. Use the IBM Garage for Cloud CLI to register the GIT Repo with Tekton or Jenkins, using `--tekton` flag if using Tekton: ```$bash oc sync [--tekton] oc pipeline ``` ### Native application development * Install [Python](https://www.python.org/downloads/) Running Flask applications has been simplified with a `manage.py` file to avoid dealing with configuring environment variables to run your app. From your project root, you can download the project dependencies with (NOTE: If you don't have pipenv installed, execute: `pip install pipenv`): ```bash pipenv install ``` Then, activate this app's virtualenv: ```bash pipenv shell ``` To run your application locally, run this inside the virtualenv: ```bash python manage.py start ``` `manage.py` offers a variety of different run commands to match the proper situation: * `start`: starts a server in a production setting using `gunicorn`. * `run`: starts a native Flask development server. This includes backend reloading upon file saves and the Werkzeug stack-trace debugger for diagnosing runtime failures in-browser. * `livereload`: starts a development server via the `livereload` package. This includes backend reloading as well as dynamic frontend browser reloading. The Werkzeug stack-trace debugger will be disabled, so this is only recommended when working on frontend development. * `debug`: starts a native Flask development server, but with the native reloader/tracer disabled. This leaves the debug port exposed to be attached to an IDE (such as PyCharm's `Attach to Local Process`). There are also a few utility commands: * `build`: compiles `.py` files within the project directory into `.pyc` files * `test`: runs all unit tests inside of the project's `test` directory Your application is running at: `http://localhost:3002/` in your browser. - Your [Swagger UI](http://swagger.io/swagger-ui/) is running on: `/explorer` - Your Swagger definition is running on: `/swagger/api` - Health endpoint: `/health` There are two different options for debugging a Flask project: 1. Run `python manage.py runserver` to start a native Flask development server. This comes with the Werkzeug stack-trace debugger, which will present runtime failure stack-traces in-browser with the ability to inspect objects at any point in the trace. For more information, see [Werkzeug documentation](http://werkzeug.pocoo.org/). 2. Run `python manage.py debug` to run a Flask development server with debug exposed, but the native debugger/reloader turned off. This grants access for an IDE to attach itself to the process (i.e. in PyCharm, use `Run` -> `Attach to Local Process`). You can also verify the state of your locally running application using the Selenium UI test script included in the `scripts` directory. > **Note for Windows users:** `gunicorn` is not supported on Windows. You may start the server with `python manage.py run` on your local machine or build and start the Dockerfile. ## License This sample application is licensed under the Apache License, Version 2. Separate third-party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the [Developer Certificate of Origin, Version 1.1](https://developercertificate.org/) and the [Apache License, Version 2](https://www.apache.org/licenses/LICENSE-2.0.txt). [Apache License FAQ](https://www.apache.org/foundation/license-faq.html#WhatDoesItMEAN)