Commit 67195b54 by rakesh.pv

Add new file

parents
from fastapi import FastAPI, Path
app = FastAPI()
students = {
1: {
"name": "john"
},
2: {
"name": "wick"
}
, 3: {
"name": "pv"
}
}
# this is our home page endpoint
@app.get("/")
def index():
return {"name": " first build"}
@app.get("/get_student/{student_id}")
def get_student(student_id: int = Path(None, description=" please specify student id", gt=0, le=3)):
return students[student_id]
@app.get("/getbyname/{student_id}")
def get_student(student_id:int,name: str):
for student_id in students:
if students[student_id]["name"] == name:
return students[student_id]
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