I've written a Flask back-end for an application I'm developing. In short, when calling http://localhost:5000/allsongs/ it returns something like (or very similar to) the following:
[["King And Lionheart", "Of Monsters And Men", "My Head Is An Animal", "mp3"], ["Just One Yesterday", "Fall Out Boy", "Save Rock And Roll", "mp3"], ["Laughter Lines", "Bastille", "All This Bad Blood", "mp3"]]
I'm trying to write a web-app using AngularJS that reads the data from that URL and uses ng-repeat to make a list that I can search through. So far, I have written this:
<!DOCTYPE html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<html ng-app="myApp">
<body>
<script>
angular.module('myApp', [])
.controller('Songs', function Songs($scope, $http) {
$http.get('http://localhost:5000/allmusic').then(function(response) {
$scope.songs = response;
});
}
);
</script>
<input placeholder="Search..." type="text" ng-model="search" />
<div ng-controller="Songs">
<p>{{songs}}</p>
</div>
<p ng-repeat="song in songs | filter:search | orderBy:name">{{ song }}</p>
</body>
</html>
All that shows up when I load the page is the search field at the top of the page.
Also, when I refresh the page I see my Flask server being called, so I know the $http.get is working somewhat.
Any advice would be great!
<div ng-controller="Songs"><p ng-repeat="song in songs | filter:search | orderBy:name">{{ song }}</p></div>XMLHttpRequest cannot load http://localhost:5000/allmusic. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access., which on the removal of the console.log was still there. Simply put, the log didn't do anything, but that error was there.