2021年3月11日星期四

Calling multiple API's from another API in python along with user requests

I am new to Flask API. I have build few API's for my project which I am calling through Postman and along with that I am passing user request in JSON format under the Postman Body.

For example:

@app.route('/data-cleaning', methods=['GET', 'POST'])  def data_cleaning():      if request.method=='GET':         user_request = request.get_json()         ....         ....         return X    @app.route('/data-transformation', methods=['GET', 'POST'])  def data_transformation():      if request.method=='GET':         user_request = request.get_json()         ....         ....         return X  

Now I am running these two services separately in Postman and within each service I am taking user_request by passing the JSON in Postman Body.

Now I want to create another API which should run both of these services along with user request. I tried to create the below script but its going in loop.

@app.route("/app2",methods=['GET', 'POST'])  def app2():      # requests.get(url, params={})      if request.method == 'GET':          res = requests.get("http://127.0.0.1:5000/data-cleaning?table=outage_data", params=                                       {"column_name": {"punctuation": "yes","stopwords": "yes",                                        "lowercase":"yes","lemetization":"yes"}})          return print('process completed')  

In the above code i just tried to run one API from another API but in actual I need to run multiple API's.

https://stackoverflow.com/questions/66594487/calling-multiple-apis-from-another-api-in-python-along-with-user-requests March 12, 2021 at 01:06PM

没有评论:

发表评论