When I try to integrate google cloud endpoints into an existing project I get this error:
ImportError: No module named endpoints
I've already added endpoints to my app.yaml file. The endpoints api file that works externally with its own app.yaml file, but gives the error when run from within the project directory. I'm routing all api calls to "endpoints_api.py" for simplicity. Maybe I'm missing something.
This is my directory setup:
-project
-handlers
-media
-templates
-webapp2_extras
__init__.py
app.yaml
main.py
endpoints_api.py
Here is my app.yaml file:
application: project-aplha
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
# Endpoints Api
- url: /_ah/spi/.*
script: endpoints_api.APPLICATION
- url: /favicon\.ico
static_files: media/favicon.ico
upload: media/favicon.ico
- url: /media
static_dir: media
# Main Script
- url: /.*
script: main.APPLICATION
libraries:
- name: endpoints
version: 1.0
- name: webapp2
version: latest
- name: jinja2
version: latest
- name: pycrypto
version: latest
And a sample of a handler class (if that matters):
class SignupHandler(base.BaseHandler):
def get(self):
return self.render_template('sighup.html')
def post(self):
name = self.request.get('name')
email = self.request.get('email')
password = self.request.get('password')
Perhaps the endpoints_api.py file too:
import endpoints
from google.appengine.ext import ndb
from protorpc import messages
from protorpc import message_types
from protorpc import remote
class Task(messages.Message):
name = messages.StringField(1, required=True)
owner = messages.StringField(2)
class TaskModel(ndb.Model):
name = ndb.StringProperty(required=True)
owner = ndb.StringProperty()
@endpoints.api(name='tasks', version='v1',
description='API for Task Management')
class TaskApi(remote.Service):
@endpoints.method(Task, Task,
name='task.insert',
path='task',
http_method='POST')
def insert_task(self, request):
TaskModel(name=request.name, owner=request.owner).put()
return request
APPLICATION = endpoints.api_server([TaskApi])