Skip to content

Example 3-26 returning a 405 Method Not Found #8

@kenlacrosse

Description

@kenlacrosse

hello.py
from fastapi import FastAPI, Header
app = FastAPI()
@app.post("/agent")
def get_agent(user_agent:str = Header()):
return user_agent

and

http -v localhost:8000/agent returns the following from HTTPie:
GET /agent HTTP/1.1
Accept: /
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: localhost:8000
User-Agent: HTTPie/3.2.2

HTTP/1.1 405 Method Not Allowed
allow: POST
content-length: 31
content-type: application/json
date: Mon, 20 May 2024 19:35:55 GMT
server: uvicorn
{
"detail": "Method Not Allowed"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions