How to bring AngularJS app and Flask on same domain?

python angularjs flask

145 просмотра

1 ответ

1200 Репутация автора

I have created a web application in AngularJS and a Flask server up and running on localhost:5000/. I wanted to make a login service, so I included the following code in my controller in AngularJS:

$scope.login = function() {
              method: 'POST',
              data: {
                username: $scope.username,
                password: $scope.password
              url: ''
            }).then(function successCallback(response) {
              }, function errorCallback(response) {

I call the login() method from the UI. But this gives me the following error:

XMLHttpRequest cannot load Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

Further when I researched on this error, I found this link, which states that my page is on a different domain than my server. How do I bring my AngularJS and python server on same domain? What piece of code will I have to specify so that in place of url:'', I just have to specify '/login'? I know this might be trivial question, but please guide me.

Автор: Prabhjot Rai Источник Размещён: 18.07.2016 03:28

Ответы (1)

0 плюса

46145 Репутация автора

Change in flask code and your url all to and then browse, then it will work.

Автор: zs2020 Размещён: 15.05.2017 03:35
Вопросы из категории :