您的项目必须至少包含以下文件:
文件和位置 | 说明 |
---|---|
/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
该文件至少需要以下内容:
其中:
main
是您的 API 服务器的 Python 模块和变量的名称。- 如果您希望 App Engine 并行发送多个请求,请将
threadsafe
设置为 true;如果希望 App Engine 按顺序发送请求,则将其设置为 false。
文件中还可包含其他可选设置。如需了解详情,请参阅 app.yaml
参考文档。但请注意,“要求登录或管理员状态”和“安全网址”下的信息不适用于后端 API。