Commit 99271261 by rakesh.pv

post exmaple 2

parent 67195b54
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
#basemodel
class detailss(BaseModel):
name:str
classs:int
age:int
@app.post("/create")
def create_student(requests:detailss):
return {f"details is crreated with student name {requests.name}"}
@app.get("/")
def index():
return " WELCOM TO MY PAGE"
details = {
1: {
"name ": " a",
"classs": 2,
"age": 20
},
2: {
"name ": " b",
"classs": 1,
"age": 10
}
}
@app.get("/class_details")
def class_details():
return details
@app.get("/find/{n}")
def find(n: int):
return details[n]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment