简体   繁体   中英

FASTAPI: what is`(..)` in the Body(...) while reading from a post request?

I am trying to read body from my POST request using FastAPI. However i am not able to understand what (...) argument for the Body function

Here is my code:

@app.post('/createPosts')
def create_post(payload: dict = Body(...)):
    print(payload)
    return {'message': 'succesfully created post'}

Probably duplicated question. Here is another one:

What does the Ellipsis object do?

It is part of Python, not FastAPI

... (Ellipsis) was the way of declaring a required parameter in FastAPI.
However, from 0.78.0, you can just omit the default value to do that.

See release note and documentation for details.

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