python - Can't to get data from flask restful api. Angularjs -
i have simple restful api on flask.
#!flask/bin/python 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 have angularjs controller 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: not receive objects (errorcallback executes).
when 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 app send request server have:
* running on http://127.0.0.1:5000/ (press ctrl+c quit) * restarting stat * debugger active! * debugger pin code: 319-334-341 127.0.0.1 - - [25/may/2016 05:58:20] "get /hello http/1.1" 200 -
when try data file or remote server ok. have problems local server.
p.s. sorry english :)
solved. had "cors header 'access-control-allow-origin' missing" error. how solve it.
Comments
Post a Comment