feat: Delete POST endpoint france
This commit is contained in:
parent
9d3a749b37
commit
277773d19c
@ -1,38 +0,0 @@
|
|||||||
from fastapi import APIRouter, HTTPException
|
|
||||||
|
|
||||||
router = APIRouter()
|
|
||||||
|
|
||||||
states_in_france = [
|
|
||||||
"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 get_states_in_france():
|
|
||||||
"""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": states_in_france
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
This code defines a FastAPI endpoint at `/france` that responds to POST requests. It returns a JSON response containing the list of states in France, along with the HTTP method used ("POST") and a special "_verb" field set to "post".
|
|
||||||
|
|
||||||
If a request is made with a method other than POST, it raises an HTTPException with a 405 Method Not Allowed status code.
|
|
||||||
|
|
||||||
The list of states is stored in the `states_in_france` variable at the top of the file.
|
|
Loading…
x
Reference in New Issue
Block a user