@endpoints.method(# This method takes a ResourceContainer defined above.ECHO_RESOURCE,# This method returns an Echo message.EchoResponse,path="echo",http_method="POST",name="echo",)defecho(self,request):output_message=" ".join([request.message]*request.n)returnEchoResponse(message=output_message)
Endpoints Frameworks 会拦截所有请求并执行所有必要的检查(例如身份验证),然后再将请求转发到 API 后端。当后端响应时,Endpoints Frameworks 会收集遥测数据并进行报告。您可以在 Google Cloud 控制台中的 Endpoints 服务页面上查看 API 的指标。
可使用带有或不带 API 管理功能的 Endpoints Frameworks。不带 API 管理功能的 Endpoints Frameworks 可免费使用。API 管理功能按照 Endpoints 价格页面的规定收费。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-18。"],[[["\u003cp\u003eCloud Endpoints Frameworks is a web framework designed for the App Engine standard Python 2.7 and Java 8 runtime environments, allowing you to generate REST APIs and client libraries.\u003c/p\u003e\n"],["\u003cp\u003eEndpoints Frameworks handles HTTP requests and responses, routing URLs to the appropriate code functions and converting return values to JSON, simplifying API development.\u003c/p\u003e\n"],["\u003cp\u003eUsing annotations in Java and decorators in Python, Endpoints Frameworks lets you define the surface of REST APIs directly within your code without the need for a third-party web server.\u003c/p\u003e\n"],["\u003cp\u003eWhile not using the Extensible Service Proxy (ESP), Endpoints Frameworks provides built-in API management comparable to ESP, including request interception, authentication, and telemetry reporting.\u003c/p\u003e\n"],["\u003cp\u003eEndpoints Frameworks is limited to the App Engine standard Python 2.7 and Java 8 environments and does not support Node.js, PHP, Go, the App Engine flexible environment, Cloud Run, Compute Engine, or Google Kubernetes Engine.\u003c/p\u003e\n"]]],[],null,["# Cloud Endpoints Frameworks is a [web\nframework](https://wikipedia.org/wiki/Web_framework) for the App Engine\nstandard [Python 2.7 and Java 8 runtime\nenvironments](/appengine/docs/standard/runtimes).\nCloud Endpoints Frameworks provides the tools and libraries that allow you to\ngenerate REST APIs and client libraries for your application.\n| **Note:** Endpoints Frameworks doesn't support the PHP, Go, or Node.js runtimes.\n\nLike other web frameworks, Endpoints Frameworks handles the low-level\ncommunication details of HTTP requests and responses for your application. When\na client sends a request to your API, Endpoints Frameworks routes the\nrequest's URL to the function or method in your code that processes the request.\nEndpoints Frameworks converts the return value to JSON and sends the\nresponse. You add metadata (by using annotations in Java and decorators in\nPython) to your source code. The metadata defines the\n[surface](/endpoints/docs/frameworks/glossary#surface) of the REST APIs for your\napplication. \n\n### Java\n\n @ApiMethod(name = \"echo\")\n public Message echo(Message message, @Named(\"n\") @Nullable Integer n) {\n return doEcho(message, n);\n }\n\nIn the example code, the\n[annotations](/endpoints/docs/frameworks/java/annotate-code) begin with\nthe `@` character.\n\n### Python\n\n @endpoints.method(\n # This method takes a ResourceContainer defined above.\n ECHO_RESOURCE,\n # This method returns an Echo message.\n EchoResponse,\n path=\"echo\",\n http_method=\"POST\",\n name=\"echo\",\n )\n def echo(self, request):\n output_message = \" \".join([request.message] * request.n)\n return EchoResponse(message=output_message)\n\nIn the example code, the\n[decorators](/endpoints/docs/frameworks/python/create_api) begin with\nthe `@` character.\n\nWith Endpoints Frameworks, you don't have to deploy a third-party web\nserver (such as Apache Tomcat or Gunicorn) with your application. You annotate\nor decorate the code and deploy your application as you normally would to the\n[App Engine standard environment](/appengine/docs/standard).\n\nAPI management\n--------------\n\nThe [Extensible Service Proxy\n(ESP)](/endpoints/docs/frameworks/glossary#extensible_service_proxy)\nprovides API management features for Endpoints for OpenAPI and\nEndpoints for gRPC. ESP runs in a container\nalongside each instance of your backend.\n\n\nBecause the App Engine standard environment didn't support\nmulti-container deployments when Endpoints Frameworks was\nunder development, Endpoints Frameworks doesn't use\nESP. Instead, Endpoints Frameworks includes a built-in\n[API gateway](https://wikipedia.org/wiki/API_management)\nthat provides API management features that are comparable to the\nfeatures that ESP provides for Endpoints for OpenAPI and\nEndpoints for gRPC.\n\n\u003cbr /\u003e\n\nEndpoints Frameworks intercepts all requests and performs any\nnecessary checks (such as authentication) before forwarding the request to the\nAPI backend. When the backend responds, Endpoints Frameworks gathers\nand reports telemetry. You can view metrics for your API on the **Endpoints\nServices** page in the Google Cloud console.\n\nYou can use Endpoints Frameworks with or without API management\nfunctionality. Use of Endpoints Frameworks without API management\nfunctionality is offered at no charge. API management functionality is charged\naccording to the [Endpoints pricing\npage](/endpoints/pricing).\n\nLimitations\n-----------\n\n- Endpoints Frameworks is supported only on the App Engine standard Python 2.7 and Java 8 runtime environments.\n- Endpoints Frameworks doesn't support the Node.js, PHP, and Go runtime environments on the App Engine standard environment.\n- Endpoints Frameworks doesn't support the App Engine flexible environment.\n- Endpoints Frameworks doesn't support Cloud Run functions, Compute Engine, and Google Kubernetes Engine.\n\nWhat's next\n-----------\n\n- To learn more about the differences between ESP and\n Endpoints Frameworks, see [Comparing Extensible Service Proxy and\n Endpoints Frameworks](/endpoints/docs/frameworks/frameworks-extensible-service-proxy#endpoints_frameworks).\n\n- For information on the language-specific libraries and tools, see the following:\n\n - [About Endpoints Frameworks for\n Java](/endpoints/docs/frameworks/java/about-cloud-endpoints-frameworks)\n - [About Endpoints Frameworks for\n Python](/endpoints/docs/frameworks/python/about-cloud-endpoints-frameworks)\n- To learn how to configure, deploy, and send requests to a sample API, see the\n following:\n\n - [Getting started with Endpoints Frameworks for Java](/endpoints/docs/frameworks/java/get-started-frameworks-java)\n - [Getting started with Endpoints Frameworks for Python](/endpoints/docs/frameworks/python/get-started-frameworks-python)"]]