angular 2 app engine - front end post request to back end

142 Views Asked by At

Hi I have an angular 2 application which i would like to deploy to gae. So back end I am using app engine python. I am trying to do a simple post request from angular front end to app engine python. So following is my app.yaml

runtime: python27
api_version: 1
threadsafe: true
service: federation-bipedal-hominids

handlers:
- url: /.*
  script: main.app

- url: (.*)/
  static_files: federation-bipedal-hominids/src/app\1/index.html
  upload: app

- url: (.*)
  static_files: app/home\1
  upload: app

main.py

import json
import webapp2
import time


# app = StaticURLParser("federation-bipedal-hominids")

def AsDict():
  return {"Hello World !": "try now"}

class RestHandler(webapp2.RequestHandler):

  def dispatch(self):
    #time.sleep(1)
    super(RestHandler, self).dispatch()


  def SendJson(self, r):
    self.response.headers['content-type'] = 'text/plain'
    self.response.write(json.dumps(r))

class HelloWorld(RestHandler):

  def post(self):

    r = AsDict()
    self.SendJson(r)

class QueryHandler(RestHandler):

  def get(self):

    r = AsDict()
    self.SendJson(r)


app = webapp2.WSGIApplication([


('/HelloWorld', HelloWorld)
], debug=True)

now, how should i do it from angular front end ?

0

There are 0 best solutions below