Skip to content

Commit 9b2ecb8

Browse files
Updated api
1 parent 74b5227 commit 9b2ecb8

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

api/api.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@
1010
app = FastAPI()
1111

1212
query_model = create_model("num", num=(int, ...))
13-
13+
api_version = "0.2.3"
1414

1515
@app.get("/")
1616
def index():
17-
return {"status": "200", "message": "Welcome to Random Profile Generator API", "version": "0.2.3"}
17+
return {"status": "200",
18+
"message": "Welcome to Random Profile Generator API",
19+
"version": api_version}
1820

1921

20-
@app.get('/api/v1/random_profile')
22+
@app.get('/api/v1/random_profile/full_profile')
2123
async def multiple_profile(params: query_model = Depends()):
2224
""" Get multiple profile with all details
2325
@@ -26,7 +28,10 @@ async def multiple_profile(params: query_model = Depends()):
2628
"""
2729
params_as_dict = params.dict()
2830
if params_as_dict['num'] > 100:
29-
return {"status": "400", "message": "Number of profiles should be less than 100"}
31+
return {"status": "400",
32+
"message": "Number of profiles should be less than 100",
33+
"version": api_version}
34+
3035
num = params_as_dict['num']
3136
profile = rp.full_profile(num)
3237
return profile
@@ -42,7 +47,10 @@ async def multiple_first_name(params: query_model = Depends()):
4247
"""
4348
params_as_dict = params.dict()
4449
if params_as_dict['num'] > 100:
45-
return {"status": "400", "message": "Number of profiles should be less than 100"}
50+
return {"status": "400",
51+
"message": "Number of profiles should be less than 100",
52+
"version": api_version}
53+
4654
num = params_as_dict['num']
4755
first_names = rp.first_name(num)
4856
return first_names
@@ -58,7 +66,10 @@ async def multiple_last_name(params: query_model = Depends()):
5866
"""
5967
params_as_dict = params.dict()
6068
if params_as_dict['num'] > 100:
61-
return {"status": "400", "message": "Number of profiles should be less than 100"}
69+
return {"status": "400",
70+
"message": "Number of profiles should be less than 100",
71+
"version": api_version}
72+
6273
num = params_as_dict['num']
6374
last_names = rp.last_name(num)
6475
return last_names
@@ -74,7 +85,10 @@ async def multiple_full_name(params: query_model = Depends()):
7485
"""
7586
params_as_dict = params.dict()
7687
if params_as_dict['num'] > 100:
77-
return {"status": "400", "message": "Number of profiles should be less than 100"}
88+
return {"status": "400",
89+
"message": "Number of profiles should be less than 100",
90+
"version": api_version}
91+
7892
num = params_as_dict['num']
7993

8094
full_names = rp.full_name(num)

0 commit comments

Comments
 (0)