AngularJS, GAE, Python Flask and CORS -


i new angularjs , have following:

  • python flask rest services running on google app engine (gae)
  • angularjs front-end running on godaddy

i have rest service i'm trying call angularjs gui. if access rest service curl, works fine, expected. i'm confident rest code not issue. know need account cors have added server side flask code:

@app.after_request def after_request(response):     response.headers.add('access-control-allow-origin', '*')     response.headers.add('access-control-allow-headers', 'origin, x-requested-with, content-type, accept')     response.headers.add('access-control-allow-methods', 'get,put,post,delete, options')     return response 

my complete client-side code looks like:

var app = angular.module('myapp', []); app.controller('formctrl', function ($scope, $http) {      app.config(['$httpprovider', function ($httpprovider) {         delete $httpprovider.defaults.headers.common['x-requested-with'];     }]);       var formdata = {         txtfirstname: "default",         txtlastname: "default",         txtemail: "default"     };      $scope.save = function() {         formdata = $scope.form;     };      $scope.submitform = function() {         console.log("posting data....");         formdata = $scope.form;          $http.post('http://myserviceurl/promo', json.stringify(formdata)).success(function(){             console.log(formdata);         });     };  }); 

but keeps on generating error of:

xmlhttprequest cannot load http://myservicelocation/promo. no 'access-control-allow-origin' header present on requested resource. origin 'http://localhost:63343' therefore not allowed access. response had http status code 500.

at point have no idea if issue client-side or server-side - thought code above should account both?!?!?! can please post end-to-end solution of headers should both client , server side?


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -