角度2和GAE端点的基本应用程序

时间:2017-05-17 17:39:16

标签: angular google-app-engine google-cloud-endpoints

应该怎么看" hello world"谷歌应用程序与角度2和端点?我试过搜索它,但只能找到信息的摘录...... like here。所以我使用角度CLI" ng new"和" ng build --prod"创建dist文件夹。然后我有谷歌端点(两个工作分开)。但它如何加入? 在我的具体案例中,我添加到我的app.yaml" dist"并且" skip_files",之后_ah / api / explorer有错误GET ... descovery ... 500 - " BackendService.getApiConfigs Error"。但是在locallhost上 - " app可以工作!" `

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

` 和

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])

1 个答案:

答案 0 :(得分:0)

要使用Google Cloud Endpoints Python Framework,请查看教程: https://cloud.google.com/endpoints/docs/frameworks/python/get-started-frameworks-python

要从Angular应用程序调用您的终端,请使用GAPI: https://developers.google.com/api-client-library/javascript/start/start-js