You must define an API server that uses the API or APIs you have created. To define an API server:
-
Create a separate module, for example,
services.py(you can use any name you want). The following sample shows what you would need to add to this file:import endpoints import your_api application = endpoints.api_server([your_api.yourApi])where
your_apiis the name of the API you are exposing. Notice that if the API is implemented in several classes,your_apiis the collection of classes, as described in Creating an API Implemented with Multiple Classes .Notice that we describe using a separate module for the API server: this is not a requirement! If you are defining multiple APIs (
remote.Servicesubclasses) that are defined in multiple files, it might be preferable to have a separate module for your API Server in order to import all these class files. However, alternatively, you could just add the requiredendpoints.api_servercode shown above to the module where you define your API. If you are defining only a single API, it may be preferable to define the API server in the same file where you define your API because it doesn't need to import any other classes. -
In your
app.yamlfile, map the API server you just created to the endpoints location as follows:handlers: # Endpoints handler - url: /_ah/spi/.* script: services.applicationwhere
servicesis the file name you used for your API server module. Notice that the endpoints path must be/_ah/spirelative to the application, not the/_ah/apipath that is used for non Endpoints applications. -
Set the runtime to Python 2.7, since Endpoints is no longer available in the Python 2.5 runtime:
application: your-app-id version: 1 runtime: python27 api_version: 1 -
Add Endpoints to the Libraries section of
app.yaml, since the Endpoints library is not included by default:libraries: - name: endpoints version: 1.0Note that you can specify the desired Endpoints library version. (Currently, the only version available is the GA version, 1.0.)