Flask

Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy, with the ability to scale up to complex applications. It began as a simple wrapper around Werkzeug and Jinja and has become one of the most popular Python web application frameworks.

Deploy your applications build using Flask framework easily using Deploy Monk.

Follow the steps in the outline of this document (on right side) to get started.


1. Code repository

1.1 Forking existing repository

We've set up a sample Flask repository (bootstrapped using Flasks's official documentation) already for you to just fork it and get started.

Goto deploymonk/backend-python-flask on GitHub and click on Fork button on top right side

Use this repository from your GitHub account when deploying.

1.2 Creating manually

Open a terminal locally and enter following command to create a basic Flask application:

Create folder

mkdir example
cd example

Create virtual environment:

pip3 install virtualenv
virtualenv venv
source venv/bin/activate

Install Flask and create requirements.txt

pip3 install flask
pip3 freeze > requirements.txt

Add an app.py file with basic Flask example code:

# File: example/app.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello world!'
if __name__ == '__main__':
app.run(host='0.0.0.0')

Test the installation by running it locally:

cd example
python app.py

Now that we have basic application setup, lets push the code to your VCS account (eg: GitHub or GitLab):

  1. Go to your VCS account website
  2. Create a new repository
  3. Copy the Git URL (eg: git@github.com:username/example.git)

Initialize git repository and commit files:

cd api
git init
git add .
git commit -m "First commit"

Add URL for the remote repository and push the changes:

git remote add origin git@github.com:username/example.git
git push -u origin master

2. Create project

  1. Open your Deploy Monk Console and click on Create Project button.
  2. Enter the Project name, select Cloud account and Server size and click on Save button to create the project.
  3. To learn more about projects, goto project section of this documentation website.

Great 🎉, you have just completed creating a new Deploy Monk project.

Project

3. Create project service

Click on Add Service button and fill in the information as follows:

  1. Service type, select Backend
  2. Language, select Python
  3. Service name, enter a name for your service
  4. Repository, select the repository created in step 1

To learn more about services, goto project services section of this documentation website.

Now click on Save button to create the new service.

Project Service

4. Deploy the project

Click on Deploy button to deploy the project and go live.

Project Deploy

5. Preview live

Click on the URL of your service to browse the live version.

Project Live

Great 🎉, you have just completed creating a new Deploy Monk project and deploying it LIVE 🙌.