question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUESTION] q could be list type ?

See original GitHub issue

hi,dear How can I set the q be list type? Is it possible ?

my request is json as down {'data': [1,2,3,4,5]}

so how to set the read_item func ? thx

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
nsidnevcommented, Apr 8, 2020

@ucas010 The standard syntax for a query parameter that contains a list of values ​​is ?q=1&q=2&q=.... If you use requests or another client library to send requests, it will act as described above.

For example, this behavior using HTTPX:

import httpx

response = httpx.get("https://google.com/path", params={'q': [1, 2, 3, 4, 5]})

assert response.request.url == 'https://google.com/path?q=1&q=2&q=3&q=4&q=5'

FastAPI handles such requests out of the box. You can do it like this:

from typing import List

from fastapi import FastAPI

app = FastAPI()


@app.get("/path")
async def route_with_list_query(q: List[int]) -> None:
    print(q)
0reactions
phy25commented, Apr 15, 2020

I am not quite sure your point here though, in Flask you probably do json.loads(request.args) while in fastapi you do json.loads(q) if you defined q in the args.

Read more comments on GitHub >

github_iconTop Results From Across the Web

css - How to use the letters "Q" and "A" inside a list in HTML
a question will be posted here. A. the answer will go here. I know I can go in and format each entry, but...
Read more >
Question Types - Qualtrics
The following table specifies which questions can be used with each project type. Please note that some questions in this list are add-ons....
Read more >
The 4 Main Types of Questions in English + Examples - Preply
In English, there are four types of questions: general or yes/no questions, special questions using wh-words, choice questions, and disjunctive ...
Read more >
This or That Questions: #1 Best List for Adults in 2022
A list of the best this or that questions for adults. Perfect to ask friends, students at work and other group settings.
Read more >
100 Getting to Know You Questions - SignUpGenius
38. Aside from necessities, what one thing could you not go a day without? 39. List two pet peeves. 40.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found