C
C
chichicken2019-08-19 20:24:19
Python
chichicken, 2019-08-19 20:24:19

How to accept data (in dictionary format) to the server?

I send data to the local Flask server

import requests
r = requests.post('http://127.0.0.1:5000/', data = {'key1':'value1'})

But I don’t understand how to correctly accept them, I found the form.to_dict(flat=False) method, but for some reason it distorts 'value1' if there were nested lists.
@app.route('/', methods=['GET', 'POST'])
def server_main():
    data = request.form.to_dict(flat=False)

Hence the question, how to properly receive data that is sent locally from the script to the local Flask server?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2019-08-19
@chichicken

Complex structures must be passed in a serialized form. For example in JSON.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question