0
from flask import Flask, jsonify, request 
from flask_restful import Resource, Api 

app = Flask(__name__)
api = Api(app)   

class display(Resource): 

def get(self): 

    return jsonify({"message":"hello world"}) 

def post(self): 

    data = request.get_json()     # status code 
    return jsonify({'data': data}), 201

class square(Resource): 


def get(self, num): 

    return jsonify({'square': num**2}) 



api.add_resource(display, '/display') 
api.add_resource(square, '/square/<int:num>') 

driver function

if __name__ == '__main__': 


app.run(port = '5008') 

This is the html file created using angularjs.This sends http request to the url given and receives data and displays it on th html page.

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>

<body>

  <div ng-app="myApp" ng-controller="myCtrl">

    <p>Today's welcome message is:</p>

    <h1>{{message}}</h1>

  </div>

  <p>The $http service requests a page on the server, and the response is set as the value of "myWelcome" variable.</p>

  <script>
    var app = angular.module('app', []);
    app.controller("myCtrl", function($http) {
      var app = this;
      $http.get("http://127.0.0.1:5008/display")
        .success(function(data) {
          app.message = data;
        })
    });
  </script>

</body>

</html>

I am getting this error while running the code: Today's welcome message is:

{{message}} The $http service requests a page on the server, and the response is set as the value of "myWelcome" variable.

georgeawg
  • 48,608
  • 13
  • 72
  • 95
  • The `.success` method was [removed from AngularJS V1.6](https://stackoverflow.com/questions/35329384/why-are-angularjs-http-success-error-methods-deprecated-removed-from-v1-6/35331339#35331339). – georgeawg Feb 04 '20 at 08:01
  • I change it and used a alternative approach,still unable to fetch the data from the url built using REST api. I have given the code below – sai kiran reddy Feb 04 '20 at 09:56
  • Look at the network tab of the Developer Console to see the error status. – georgeawg Feb 04 '20 at 16:18

0 Answers0