All Products
Search
Document Center

:Create a ZIP package for a Python application

Last Updated:Sep 03, 2024

You can create a ZIP package for an existing on-premises PHP application or the PHP application that you create on your on-premises machine. You can use the ZIP package to deploy the application in Serverless App Engine (SAE). This topic describes the directory structure of the ZIP package and how to deploy an application by using the ZIP package.

Directory structure of the ZIP package

  • You can add only the file or folder in which the application code is stored to the ZIP package. You do not need to include the parent directory of the file or folder.

  • If a requirements.txt file is available for an application, you must place the file in the root directory of the package for SAE to install dependencies.

If you want to deploy an application, you can create a ZIP package based on the demo application package that includes the configurations of Gunicorn and Flask. Then, you can upload the package to SAE to deploy the application. In this example, the demo application package is used. For more information, see hello-sae-python.zip.

.
├── app
│   └── hello.py
└── requirements.txt (Optional. This file must be placed in the root directory of the package.)

Step 1: Create a ZIP package for a Python application

Run commands or use a file compression tool to include the application directory in a ZIP package. The following section describes how to create the ZIP package by running commands.

  1. Run the following command to download the demo application package:

    wget https://sae-demo-cn-shenzhen.oss-cn-shenzhen.aliyuncs.com/demo/1.0/hello-sae-python.zip
  2. Run the following command to decompress the package:

    unzip hello-sae-python.zip
  3. Optional:Add custom code for your application based on your business requirements.

  4. Run the following command to create the package:

    zip -r hello-sae-python.zip app requirements.txt

Step 2: Deploy the Python application

Procedure

For more information, see Deploy a Python application by using a ZIP package in the SAE console.

Additional configurations for the application

Run the following command to start the container. Set the Startup Method parameter to Shell Script and enter the command in the text box that appears.

gunicorn -w 3 -b 0.0.0.0:8080 app.hello:app

sc_startup_command_for_ptyhon_application_via_shell