I have a very simple restful api on flask.
#!flask/bin/python
from flask import Flask, jsonify, Response
app = Flask(__name__)
@app.route('/todo/api/v1.0/notes', methods=['GET'])
def get_tasks():
return jsonify({'key': 'value'})
if __name__ == '__main__':
app.run(debug=True)
And I have AngularJS controller like this:
var app = angular.module('notesApp',['angular-markdown-editable']);
app.controller('notesController',function($scope, $http, $window){
$http({
method: 'GET',
url: "http://127.0.0.1:5000/hello"
}).then(function successCallback(response) {
$window.alert(":)");
}, function errorCallback(response) {
$window.alert(":(");
});
});
Problem: i do not receive any objects (errorCallback always executes).
When i try:
curl -i http://127.0.0.1:5000/hello
i have result:`
HTTP/1.0 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 5
Server: Werkzeug/0.11.10 Python/2.7.6
Date: Wed, 25 May 2016 03:09:54 GMT
Hello
When my app send request to the server i have:
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger pin code: 319-334-341
127.0.0.1 - - [25/May/2016 05:58:20] "GET /hello HTTP/1.1" 200 -
When i try to get data from file or remote server all is ok. I have problems only with my local server.
P.S. Sorry for my English :)