Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fastapi
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kl_internship
fastapi
Commits
67195b54
Commit
67195b54
authored
Jan 24, 2023
by
rakesh.pv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parents
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
main.py
+33
-0
No files found.
main.py
0 → 100644
View file @
67195b54
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
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment