Flask is a Python-based light-weight Web framework. This topic describes how to use Flask to create an application and deploy the application in Web+.
Step 1: Create an application.
- Create a directory named weplusdemo and create a file named application.py in the directory.
webplusdemo └── application.py
- Add the following snippet to the application.py file.
from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello World!
Notice- Web+ automatically identifies the application.py file and the global variable named app. If you want to use a different file name, you must specify the required start command in the Procfile file or Web+ console. For more information, see Use the Procfile file to configure application processes and Commands and lifecycle hooks.
- Web+ uses Gunicorn as the HTTP server for Flask applications by default.
Step 2: Create a deployment package
Go to the webplusdemo directory, and use the following command to create a deployment package named webplusdemo.zip.
zip -r webplusdemo.zip . /
Step 3: Deploy the application in Web+
- Log on to the Web+ console.
- On the Overview page, click Create in the Last Updated Environments section.
- In the Basic Information step, select Python in the Technology Stack Type field and enter an application name and description. After the configuration is complete, click Next.
- In the Environment Information step, enter a environment name, select Upload Local Application in the Deployment Package Source field, and upload the webplusdemo.zip deployment package. After configuring the deployment package version, click Creation Complete.
- In the Creation Complete step, click View Application or Creation Complete to go to the Overview tab of the Application Details page. Click the name of an environment to go to the Overview tab of the Environment Details page. Then, click the link next to the Public IP Address label to view the homepage of the application.
More information
- For more information about how to deploy an application in the console, see Deploy an application.
- For more information about how to use the CLI tool to create and deploy an application, see Use the CLI to quickly deploy applications.
- For more information about management tasks after you host an application, see Overview of application details.
- For more information about how to manage deployment environments where applications reside, see Deployment environment overview.