This guide is aimed at the Flask developer who would like to create and launch a new project running on Divio's Docker-based Cloud.
The guide assumes that you are already familiar with Flask and key developer tools such as Git.
Important: The Flask project type is offered as a public beta. We welcome feedback from users to help us improve it.
Before we begin
If you are not already familiar with the Divio infrastructure, Control Panel and local development environment, please make use of some key topics and resources:
- General overview of the Control Panel More information about your account, project settings and more.
- How to create a new Divio project Additional detail about project creation options.
- Our Developer Handbook.
Create a new Flask project
In the Control Panel, create a new project with the following configuration:
- Platform: Python
- Type: Flask
- Boilerplate: Default
Set up the project locally
Run Setup to clone and build
Select the project and hit Setup in the Divio app:
or use the Divio CLI:
divio project setup <project slug>
to set the project up locally. This will take a few minutes to:
- clone the project's Git repository
- execute the commands in its
Dockerfileto build the project image
Your Flask project is now ready to launch.
You will find:
flaskrdirectory, as described in the Flask tutorial
- other directories, related to Divio
Note: the Flask project type is currently offered as a Beta, and you will find that the project contains some extraneous files and directories that can simply be ignored. Future versions will present a cleaner project directory.
Launch the server
- hit Start (Divio app), or,
docker-compose up(Divio CLI)
to launch the local server.
Now you can open your local website using the "eye" icon on the top right of the Local Server in the Divio App, or open http://127.0.0.1:8000 in a browser, where you'll see a Hello, World message.
Interacting with the local project
Your project runs in a Docker container. While the
web container is already running you can execute commands in it using
docker-compose exec web <command> . For example to launch a bash shell:
docker-compose exec web bash
You can also use
docker-compose run --rm web <command> to launch a container and run a command in it.
You can push code (using Git) and database and media (using the Divio tools) to the Divio platform and deploy your project on a Cloud server.
Our Developer Handbook is the recommended source for further information about using the platform as a developer.
The Flask official tutorial offers a project that will help you explore Flask on Divio.
About your Divio Flask project
Your Flask application may require a database. Our projects provide Postgres databases in the Live, Test and local environments.
In each environment, the
DEFAULT_DATABASE_DSN environment variable will provide the database credentials.
DEFAULT_DATABASE_DSN provides credentials for the environment's S3 media storage on Live and Test. For the local environment, you should use local file storage instead, using the