必需的文件和配置

您的项目必须至少包含以下文件:

文件和位置 说明
/src/<your_api_class>.py 包含后端 API 的类文件(如果是跨多个类实现的 API,则为多个文件)。
/src/<your_api_server>.py 包含 API 服务器代码的可选文件(如果未将其纳入 API 类中)。
/src/app.yaml App Engine 配置所需的 Web 应用部署描述符。

以下各部分记录了每个所需文件的内容。

API 类文件

如需查看该类文件(如果您使用多类 API,则为多个类文件)的必需内容和可选内容的完整说明,请参阅创建 Endpoints API 主题。

API 服务器文件

如需此文件及其内容的完整说明,请参阅创建 Web 服务器。

app.yaml

该文件至少需要以下内容:

# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

runtime: python27
threadsafe: true
api_version: 1
basic_scaling:
  max_instances: 2

skip_files:
- ^(.*/)?#.*#$
- ^(.*/)?.*~$
- ^(.*/)?.*\.py[co]$
- ^(.*/)?.*/RCS/.*$
- ^(.*/)?\..*$
- ^(.*/)?setuptools/script \(dev\).tmpl$

handlers:
# The endpoints handler must be mapped to /_ah/api.
- url: /_ah/api/.*
  script: main.api

libraries:
- name: pycrypto
  version: 2.6
- name: ssl
  version: 2.7.11