This is a basic Flask to-do app that can be deployed with Defang. Note that alongside your .py
file, include a requirements.txt
so that the Dockerfile can install the necessary packages with pip.
This project is intended to provide a basic understanding of how to get started with Flask on Defang. The items are stored in memory and are lost when the server is restarted. It is not intended for production use. If you need something production ready, you should use a managed database like Postgres or MySQL.
- Download Defang CLI
- (Optional) If you are using Defang BYOC authenticate with your cloud provider account
- (Optional for local development) Docker CLI
To run the application locally, you can use the following command:
docker compose up --build
For this sample, you will not need to provide configuration.
If you wish to provide configuration, see below for an example of setting a configuration for a value named API_KEY
.
defang config set API_KEY
Note
Download Defang CLI
Deploy your application to the Defang Playground by opening up your terminal and typing:
defang compose up
If you want to deploy to your own cloud account, you can use Defang BYOC:
- Authenticate your AWS account, and check that you have properly set your environment variables like
AWS_PROFILE
,AWS_REGION
,AWS_ACCESS_KEY_ID
, andAWS_SECRET_ACCESS_KEY
. - Run in a terminal that has access to your AWS environment variables:
defang --provider=aws compose up
Title: Flask
Short Description: A basic Flask to-do app.
Tags: Flask, Python
Languages: python