M
M
Medelin02018-04-01 18:38:21
Flask
Medelin0, 2018-04-01 18:38:21

How in Flask to distinguish between incoming requests to the server?

There is a script and there is a server.
The script sends requests:

re= requests.post('http://127.0.0.1:5000', json=somedata1)
re2 = requests.post('http://127.0.0.1:5000', json=somedata2)

The server accepts requests:
@app.route("/", methods=['GET', 'POST'])
def  index():
  temp1 = request.get_json()
  temp2= request.get_json()

And here's the problem, both requests end up in temp1. How to make re1 go to temp1 and re2 go to temp2

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2018-04-02
@vintello

in fact, everything is simple. in json, you must add a mandatory parameter of the type "command": "first" or "command": "second" and, depending on this parameter, already assign either the entire data set or its part to the variable temp1 or temp2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question