0
import requests
r = requests.get('http://0.0.0.0:5000/segment?text=this is a test')

This 'get' receives text one by one. Can the 'get' receives a list of value as an URL parameter, as follows:

texts = ['this is a test', 'this is a test2', 'this is a test3']

Isn't this a typical use case?

marlon
  • 6,029
  • 8
  • 42
  • 76
  • Does this answer your question? [List of query params with Flask request.args](https://stackoverflow.com/questions/57914396/list-of-query-params-with-flask-request-args) – Dušan Maďar Jun 12 '20 at 18:44
  • @DušanMaďar I saw that example and it makes sense to me. However, I have a question, is that normal to pass a huge list of values to the parameters? In my case, the list could be 100000 sentences per request. The http client is processing a file of plain text and 100000 sentences are desired to be sent to server for processing for each request. Is this normal use of http call? – marlon Jun 12 '20 at 20:56
  • Well, the URL length is limited, google "maximum url length", so I doubt you would be able to pass thousands of sentences. I would use POST, not GET, request and pass the data in the request body, e..g a [compressed] text file, or stream it. – Dušan Maďar Jun 12 '20 at 21:26
  • Related: https://stackoverflow.com/questions/2880722/can-http-post-be-limitless – Dušan Maďar Jun 12 '20 at 21:33
  • @DušanMaďar, I don't care it's get or post, as long as it works. My file is actually JSON file, which contains many lines. Is there a way to directly pass potentially big JSON object to it as URL parameter? – marlon Jun 12 '20 at 21:57
  • Yes, you can encode a JSON string and use it in query params, see https://stackoverflow.com/questions/8293113/why-i-cant-use-urlencode-to-encode-json-format-data. However, due to the above mentioned URL length limit, I don't think it can be a big JSON. – Dušan Maďar Jun 13 '20 at 06:50

0 Answers0