Passing Parameters from Javascript to flask python script
Question: I am new to flask so bare with me.

Currently I have a angularjs file which uses $http.get to call my python flask
script.

In this flask script I want to then call another python script (which is
running pySolr), however the http.get call contains a parameter I wish to pass
to this pySolr script.

Is there any documentation on this/ can it actually be done?

    
    
    $http.get('http://localhost:5000/python/solr', "$scope.tag");
    console.log($scope.tag);
    

$scope.tag is the variable I need to get

My flask file is as follows:

    
    
    from flask import Flask
    app = Flask(__name__)
    
    @app.route('/python/solr')
    def solr():
        "MY CODE TO CALL SOLR SCRIPT GOES HERE"
    
    
    if __name__ == "__main__":
    app.run()
    

any help would be greatly appreciated!


Answer: You should be able to do this using query parameters:

    
    
    $http.get('http://localhost:5000/python/solr?tag=' + $scope.tag);
    console.log($scope.tag);
    

In flask

    
    
    from flask import request
    
    @app.route('/python/solr')
    def solr():
        print request.args  # should get tag here
    

