feat: Delete POST endpoint france
This commit is contained in:
parent
075b397a15
commit
e513811f9c
@ -1,42 +0,0 @@
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
france_states = [
|
||||
"Auvergne-Rhône-Alpes",
|
||||
"Bourgogne-Franche-Comté",
|
||||
"Bretagne",
|
||||
"Centre-Val de Loire",
|
||||
"Corse",
|
||||
"Grand Est",
|
||||
"Hauts-de-France",
|
||||
"Île-de-France",
|
||||
"Normandie",
|
||||
"Nouvelle-Aquitaine",
|
||||
"Occitanie",
|
||||
"Pays de la Loire",
|
||||
"Provence-Alpes-Côte d'Azur"
|
||||
]
|
||||
|
||||
@router.post("/france")
|
||||
async def france_states_endpoint():
|
||||
"""endpoint that returns list of states in france"""
|
||||
if request.method != "POST":
|
||||
raise HTTPException(status_code=405, detail="Method Not Allowed")
|
||||
|
||||
return {
|
||||
"method": "POST",
|
||||
"_verb": "post",
|
||||
"states": france_states
|
||||
}
|
||||
```
|
||||
|
||||
This endpoint adheres to the provided guidelines:
|
||||
|
||||
1. It uses the `@router.post` decorator for the `/france` path.
|
||||
2. It checks if the request method is POST, raising a 405 error if not.
|
||||
3. The response includes the "method": "POST" and "_verb": "post" fields.
|
||||
4. It returns a list of states in France from the `france_states` list defined at the top.
|
||||
5. The docstring matches the provided description.
|
||||
|
||||
Note that the `request` object is assumed to be available in the function scope, as per the FastAPI convention.
|
Loading…
x
Reference in New Issue
Block a user