简体   繁体   中英

creating a python server that can take in requests from postman

I am trying to create a web app. One of the components is a ML algo that is built on Python. For development, I would like the Python file to be on a server so that I can use postman to send requests to it. I have looked at several articles and I am not quite sure how to do it.

Can anyone help?

Reproducible python code

 def analyzeCars(data):
   print(data)

I would like to be able to pass data into this script using Postman on a server.

Thanks

You can follow Django Rest framework Quickstart to get along with your first API creation.

If you would like to use flask then you can follow below tutorials

Check below basic HTTP method from flask documentation

from flask import request

@app.route('/analyzeCars', methods=['POST'])
def CarAnalysis():
    if request.method == 'POST':
        analyzeCars(request.data)
        return {"status":"success"}
    

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM