0

How should look "hello world" google app with angular 2 and endpoint? I've tried search it, but can find just excerpts of information... like here. So I use angular CLI "ng new", and "ng build --prod" to create dist folder. Then I have google endpoints (both work separate). But how it join? In my concrete case I add to my app.yaml "dist" and "skip_files", after that _ah/api/explorer have error GET ...descovery... 500 - "BackendService.getApiConfigs Error". But on locallhost - "app works!" `

application: graphgroop
version: 1
runtime: python27
threadsafe: true
api_version: 1

handlers:
- url: /(.+)
  static_files: dist/\1
  upload: dist/(.*)
  secure: always
- url: /
  static_files: dist/index.html
  upload: dist/index.html
  secure: always
- url: /.*
  script: endp.app
  secure: always
- url: /_ah/spi/.*
  script: GG.app
  secure: always
# Temporary setting to keep gcloud from uploading not required files for deployment
skip_files:
- ^node_modules$
- ^app\.yaml
- ^README\..*
- \.gitignore
- ^\.git$
- ^grunt\.js
- ^src$
- ^e2e$
- \.editorconfig
- ^karma\.config\.js
- ^package\.json
- ^protractor\.conf\.js
- ^tslint\.json

libraries:
- name: endpoints
  version: 1.0

- name: pycrypto
  version: latest

inbound_services:
- mail

builtins:
- remote_api: on

` And

import endpoints
from protorpc import messages
from protorpc import message_types
from protorpc import remote
from google.appengine.ext import ndb

JS_CLIENT_ID = '6**********************.googleusercontent.com'

class Answer(messages.Message):
    ans = messages.StringField(1)

class Base(ndb.Expando):
    name = ndb.StringProperty()

@endpoints.api(name='sss', version='v1', allowed_client_ids=[
endpoints.API_EXPLORER_CLIENT_ID,
JS_CLIENT_ID
],
scopes=[endpoints.EMAIL_SCOPE])
class Try(remote.Service):
    @endpoints.method(Answer,
                      Answer,
                      path='answer',
                      http_method='PUT',
                      name='answer')
    def answer(self, message):
        entity = Base(name=message.ans)
        entity.put()
        return Answer(ans='Sucses: ' + message.ans )


app = endpoints.api_server([Try])
Community
  • 1
  • 1

1 Answers1

0

For using the Google Cloud Endpoints Python Framework, take a look at the tutorial: https://cloud.google.com/endpoints/docs/frameworks/python/get-started-frameworks-python

And to call your Endpoints from an Angular app, use GAPI: https://developers.google.com/api-client-library/javascript/start/start-js

Wesley Wong
  • 459
  • 2
  • 2