You must define an API server that uses the API or APIs you have created. To define an API server:
Create a Python module, for example
main.py, and create an
endpoints.api_serverobject at the top-level:
api = endpoints.api_server([EchoApi])
Note that you provide a list of
remote.Serviceobjects to the API server. If you have an API that is is implemented in several classes, then your
Serviceobject is a collection of classes as described in Creating an API Implemented with Multiple Classes.
A separate module is not required when describing an API. If you are defining multiple APIs (
remote.Servicesubclasses) that are defined in multiple files, then it is recommended to have a separate module for your API server in order to import all these class files.
Alternatively, add the required
endpoints.api_servercode to the module where you define your API. If you are defining only a single API, define the API server in the API definition file because it doesn't need to import any other classes.
app.yamlfile, map the API server you just created to the endpoints location as follows:
handlers: # The endpoints handler must be mapped to /_ah/api. - url: /_ah/api/.* script: main.api
mainis the Python module you used for your API server module.
Serving your API from a different path
Optional: To serve your API from a different path, for example
Modify the decorator:
@endpoints.api(name='echo', version='v1', base_path='/api/')
handlers: - url: /api/.* script: main.api